标签:
-- call UpdateProvinceSalePriceTmp();
SELECT categorysync.SyncNum, id,CODE, corpid,corpcode,customertypeid,grouptype,groupcode,pricemethods,IsForced,category.SalePrice,`Precision`,`Retentionway`,`status` FROM PricingCategory category JOIN PricingCategory_SYNC categorysync ON category.Id=BillId JOIN schedulelog LOG ON categorysync.SyncNum> log.syncnum WHERE log.tagbillname=‘PricingCategory‘ AND category.status=2 and category.GroupType=3 ORDER BY categorysync.SyncNum where grouptype=1 LIMIT 100000;
select * from schedulelog 352717 333415 31105 33808 select * from schedulelog
SELECT categorysync.SyncNum, id,CODE, corpid,corpcode,customertypeid, grouptype,groupcode,pricemethods,IsForced,SalePrice,`Precision`,`Retentionway`,`status` ,ModifyPriceWay,ProvinceSalePrice FROM ProvincePricingCategory category JOIN ProvincePricingCategory_SYNC categorysync ON category.Id=BillId JOIN schedulelog LOG ON categorysync.SyncNum> log.syncnum WHERE log.tagbillname=‘ProvincePricingCategory‘ AND category.status=2 and category.GroupType=3 ORDER BY categorysync.SyncNum LIMIT 170000;
SELECT * FROM INFORMATION_SCHEMA.INNODB_LOCK_WAITS
SELECT * FROM INFORMATION_SCHEMA.INNODB_LOCKs
SELECT * FROM INFORMATION_SCHEMA.INNODB_TRX show engine innodb status show PROCESSLIST kill 944
SELECT r.trx_id AS waiting_trx_id, r.trx_mysql_thread_id AS waiting_thread, TIMESTAMPDIFF(SECOND, r.trx_wait_started, CURRENT_TIMESTAMP) AS wait_time, r.trx_query AS waiting_query, l.lock_table AS waiting_table_lock, b.trx_id AS blocking_trx_id, b.trx_mysql_thread_id AS blocking_thread, SUBSTRING(p.host,1,INSTR(p.host, ‘:‘) -1 ) AS blocking_host, SUBSTRING(p.host, INSTR(p.host, ‘:‘) +1 ) AS block_port, IF(p.command="Sleep",p.time,0) AS idle_in_trx, b.trx_query AS blcoking_query from information_schema.innodb_lock_waits AS w INNER JOIN information_schema.innodb_trx AS b ON b.trx_id=w.blocking_trx_id INNER JOIN information_schema.innodb_trx AS r ON r.trx_id = w.requesting_trx_id INNER JOIN information_schema.innodb_locks AS l ON w.requested_lock_id = l.lock_id LEFT JOIN information_schema.processlist AS p ON p.id = b.trx_mysql_thread_id ORDER BY wait_time DESC
SELECT CONCAT(‘thread ‘, b.trx_mysql_thread_id, ‘ from ‘,p.host) AS who_blocks, IF (p.command = "Sleep",p.time, 0) AS idle_in_trx, MAX(TIMESTAMPDIFF(SECOND,r.trx_wait_started,NOW())) AS max_wait_time, COUNT(*) AS num_waiters FROM information_schema.innodb_lock_waits as w inner join information_schema.innodb_trx as b on b.trx_id = w.blocking_trx_id inner join information_schema.innodb_trx as r on r.trx_id = w.requesting_trx_id left join information_schema.processlist as p on p.id = b.trx_mysql_thread_id group by who_blocks order by num_waiters desc
SELECT CONCAT(‘thread ‘ , b.trx_mysql_thread_id , ‘ from ‘ , p.host) as who_blocks, IF(p.command = "Sleep", p.time, 0 ) as idle_in_trx, MAX(TIMESTAMPDIFF(SECOND, r.trx_wait_started, NOW() )) as max_wait_time, COUNT(*) as num_waiters FROM INFORMATION_SCHEMA.INNODB_LOCK_WAITS AS w INNER JOIN INFORMATION_SCHEMA.INNODB_TRX AS b ON b.trx_id = w.blocking_trx_id INNER JOIN INFORMATION_SCHEMA.INNODB_TRX AS r ON b.trx_id = w.requesting_trx_id LEFT JOIN INFORMATION_SCHEMA.PROCESSLIST AS p ON p.id = b.trx_mysql_thread_id GROUP BY who_blocks ORDER BY num_waiters DESC
select r.trx_id as waiting_trx_id, r.trx_mysql_thread_id as waiting_thread, timestampdiff(second, r.trx_wait_started, current_timestamp) as wait_time, r.trx_query as waiting_query, l.lock_table as waiting_table_lock, b.trx_id as blocking_trx_id, b.trx_mysql_thread_id as blocking_thread, substring(p.host, 1, instr(p.host, ‘:‘) - 1) as blocking_host, substring(p.host, instr(p.host, ‘:‘) + 1) as blocking_port, if(p.command = "Sleep" , p.time, 0) as idle_in_trx, b.trx_query as blocking_query FROM INFORMATION_SCHEMA.INNODB_LOCK_WAITS AS w INNER JOIN INFORMATION_SCHEMA.INNODB_TRX AS b ON b.trx_id = w.blocking_trx_id INNER JOIN INFORMATION_SCHEMA.INNODB_TRX AS r ON b.trx_id = w.requesting_trx_id INNER JOIN INFORMATION_SCHEMA.INNODB_LOCKS AS l ON w.requested_lock_id = l.lock_id LEFT JOIN INFORMATION_SCHEMA.PROCESSLIST AS p ON p.id = b.trx_mysql_thread_id ORDER BY wait_time DESC
SELECT r.trx_id waiting_trx_id, r.trx_mysql_thread_id waiting_thread, r.trx_query waiting_query, b.trx_id blocking_trx_id, b.trx_mysql_thread_id blocking_thread, b.trx_query blocking_query FROM information_schema.innodb_lock_waits w INNER JOIN information_schema.innodb_trx b ON b.trx_id = w.blocking_trx_id INNER JOIN information_schema.innodb_trx r ON r.trx_id = w.requesting_trx_id
SELECT r.trx_id waiting_trx_id, r.trx_mysql_thread_id waiting_thread, TIMESTAMPDIFF( SECOND, r.trx_wait_started, CURRENT_TIMESTAMP ) wait_time, r.trx_query waiting_query, l.lock_table waiting_table_lock, b.trx_id blocking_trx_id, b.trx_mysql_thread_id blocking_thread, SUBSTRING( p. HOST, 1, INSTR(p. HOST, ‘:‘) - 1 ) blocking_host, SUBSTRING(p. HOST, INSTR(p. HOST, ‘:‘) + 1) blocking_port, IF (p.COMMAND = ‘Sleep‘, p.TIME, 0) idel_in_trx, b.trx_query blocking_query FROM information_schema.INNODB_LOCK_WAITS w INNER JOIN information_schema.INNODB_TRX b ON b.trx_id = w.blocking_trx_id INNER JOIN information_schema.INNODB_TRX r ON r.trx_id = w.requesting_trx_id INNER JOIN information_schema.INNODB_LOCKS l ON w.requested_lock_id = l.lock_id LEFT JOIN information_schema. PROCESSLIST p ON p.ID = b.trx_mysql_thread_id ORDER BY wait_time DESC;
select * from schedulelog SELECT INFORMATION_SCHEMA.INNODB_TRX.*, PROCESSLIST.INFO, TIMESTAMPDIFF(SECOND, trx_started, SYSDATE()) as trx_runtime_seconds, TIMESTAMPDIFF(SECOND, trx_wait_started, SYSDATE()) as trx_wait_seconds, IF(PROCESSLIST.COMMAND = ‘Sleep‘, PROCESSLIST.TIME, 0) AS trx_idle_seconds, CONCAT(‘KILL QUERY ‘, trx_mysql_thread_id) AS sql_kill_query, CONCAT(‘KILL ‘, trx_mysql_thread_id) AS sql_kill_connection FROM INFORMATION_SCHEMA.INNODB_TRX LEFT JOIN INFORMATION_SCHEMA.PROCESSLIST ON (trx_mysql_thread_id = PROCESSLIST.ID)
show PROCESSLIST
SELECT r.trx_id waiting_trx_id, r.trx_mysql_thread_id waiting_thread, r.trx_query waiting_query, b.trx_id blocking_trx_id, b.trx_mysql_thread_id blocking_thread, b.trx_query blocking_query FROM information_schema.innodb_lock_waits w INNER JOIN information_schema.innodb_trx b ON b.trx_id = w.blocking_trx_id INNER JOIN information_schema.innodb_trx r ON r.trx_id = w.requesting_trx_id;
select * from schedulelog
WHERE trx_mysql_thread_id != CONNECTION_ID()
KILL QUERY 1266
show PROCESSLIST
DELIMITER // CREATE EVENT CallUpdateSalePrice ON SCHEDULE EVERY 1 MINUTE STARTS TIMESTAMP(CURRENT_DATE,‘23:00:00‘) ENDS TIMESTAMP(ADDDATE(CURRENT_DATE,1),‘06:00:00‘) DO BEGIN CALL UpdateSalePriceTmp(); END//
DELIMITER // CREATE EVENT CallUpdateProvinceSalePrice ON SCHEDULE EVERY 1 MINUTE STARTS TIMESTAMP(CURRENT_DATE,‘23:00:00‘) ENDS TIMESTAMP(ADDDATE(CURRENT_DATE,1),‘06:00:00‘) DO BEGIN CALL UpdateProvinceSalePriceTmp(); END// select ADDDATE(CURRENT_DATE,1)
select * from schedulelog 352717 333415 31105 33808 show PROCESSLIST update UPDATE schedulelog SET SyncNum =31105 ,ModifyTime=NOW() WHERE TagBillName=‘PricingCategory‘; UPDATE schedulelog SET SyncNum =333415,ModifyTime=NOW() WHERE TagBillName=‘ProvincePricingCategory‘; call UpdateProvinceSalePriceTmp CALL updatesalepricetmp
标签:
原文地址:http://www.cnblogs.com/naliang/p/5449085.html