QueueMetrics > Running QueueMetrics
Got 3 identical SQL records for a single call
(1/1)
Bruno GUIBERT - Telnowedge:
Need to know how to purge SQL database of duplicated entry
merci
QueueMetrics:
Do the following (requires MySQL 5):
1. Stop all qloaderd's - you should see no data being appended
2. Create a new table called queue_log_b that has the same definition as your current queue_log table:
--- Code: ---CREATE TABLE `queue_log_b` (
`partition` varchar( 20 ) NOT NULL default '',
`time_id` int( 11 ) unsigned NOT NULL default '0',
`call_id` varchar( 30 ) NOT NULL default '',
`queue` varchar( 30 ) NOT NULL default '',
`agent` varchar( 30 ) NOT NULL default '',
`verb` varchar( 30 ) NOT NULL default '',
`data1` varchar( 30 ) NOT NULL default '',
`data2` varchar( 30 ) NOT NULL default '',
`data3` varchar( 30 ) NOT NULL default '',
`data4` varchar( 30 ) NOT NULL default '',
`serverid` varchar( 10 ) NOT NULL default '',
`unique_row_count` int( 10 ) unsigned NOT NULL AUTO_INCREMENT ,
KEY `idx_sel` ( `partition` , `time_id` , `queue` ( 2 ) ) ,
KEY `partizione_b` ( `partition` , `time_id` , `unique_row_count` ) ,
KEY `by_hotdesk` ( `partition` ( 5 ) , `verb` ( 5 ) , `time_id` )
) ENGINE = MYISAM DEFAULT CHARSET = latin1;
--- End code ---
3. Copy all data from queue_log to queue_log_b
--- Code: ---INSERT INTO queue_log_b
SELECT *
FROM queue_log
--- End code ---
4. Delete the queue_log table
--- Code: ---TRUNCATE TABLE queue_log
--- End code ---
5. Copy all unique rows back to queue_log
--- Code: ---INSERT INTO queue_log (
SELECT `partition`, `time_id`, `call_id`, `queue`, `agent`,
`verb`, `data1`, `data2`, `data3`, `data4`,
`serverid`, MIN(`unique_row_count`)
FROM queue_log_b
GROUP BY `partition`, `time_id`, `call_id`, `queue`,
`agent`, `verb`, `data1`, `data2`, `data3`,
`data4`, `serverid`
ORDER BY time_id, MIN(unique_row_count)
)
--- End code ---
this may take a while.
6. Restart ONE instance of qloaderd.
Bruno GUIBERT - Telnowedge:
Be carefull : some QM queue_log table doesn't include (yet) serverid field ???
--- Code: ---
describe queue_log;
+------------------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------------+------------------+------+-----+---------+----------------+
| partition | char(20) | NO | MUL | | |
| time_id | int(11) unsigned | NO | | 0 | |
| call_id | char(30) | NO | | | |
| queue | char(30) | NO | | | |
| agent | char(30) | NO | | | |
| verb | char(30) | NO | | | |
| data1 | char(30) | NO | | | |
| data2 | char(30) | NO | | | |
| data3 | char(30) | NO | | | |
| data4 | char(30) | NO | | | |
| unique_row_count | int(11) | NO | PRI | NULL | auto_increment |
+------------------+------------------+------+-----+---------+----------------+
--- End code ---
the SQL statements are
CREATE
--- Code: ---CREATE TABLE `queue_log_b`
( `partition` varchar( 20 ) NOT NULL default '', `time_id` int( 11 ) unsigned NOT NULL default '0',
`call_id` varchar( 30 ) NOT NULL default '', `queue` varchar( 30 ) NOT NULL default '',
`agent` varchar( 30 ) NOT NULL default '', `verb` varchar( 30 ) NOT NULL default '',
`data1` varchar( 30 ) NOT NULL default '', `data2` varchar( 30 ) NOT NULL default '',
`data3` varchar( 30 ) NOT NULL default '', `data4` varchar( 30 ) NOT NULL default '',
`unique_row_count` int( 10 ) unsigned NOT NULL AUTO_INCREMENT ,
KEY `idx_sel` ( `partition` , `time_id` , `queue` ( 2 ) ) ,
KEY `partizione_b` ( `partition` , `time_id` , `unique_row_count` ) ,
KEY `by_hotdesk` ( `partition` ( 5 ) , `verb` ( 5 ) , `time_id` ) )
ENGINE = MYISAM DEFAULT CHARSET = latin1
;
--- End code ---
COPY
--- Code: ---INSERT INTO queue_log
( SELECT `partition`, `time_id`, `call_id`, `queue`, `agent`,
`verb`, `data1`, `data2`, `data3`, `data4`,MIN(`unique_row_count`)
FROM queue_log_b
GROUP BY `partition`, `time_id`, `call_id`, `queue`,
`agent`, `verb`, `data1`, `data2`, `data3`, `data4`
ORDER BY 'time_id', MIN('unique_row_count')
);
--- End code ---
PLS ADD CLEANUP
--- Code: ---DROP table queue_log_b;
--- End code ---
QueueMetrics:
You had a funny mistake - nice we found the problem!
;D
Navigation
[0] Message Index
Go to full version