Re: Sort_merge_passes increasing at 38 per minute...
SHOW VARIABLES LIKE 'innodb%';
SHOW STATUS LIKE 'Innodb%';
What version?
InnoDB does have periodic pauses while it flushes things to disk. But I generally see the frequency to be hours, not "1-2 times per minute". (Percona's Xtradb has virtually eliminated this issue.)
SHOW CREATE TABLE
SHOW TABLE STATUS
Sort merge passes should happen on large sorts, no 4000-row sorts -- unless
* Certain settings are unreasonably low;
* The table rows are really fat (big TEXT/BLOG field(s)).
SELECT end_time INTO currentEndTime FROM auctions WHERE id=var_auction_id;
IF (ADDTIME(currentEndTime , var_time_increment) < NOW()) THEN
UPDATE auctions SET end_time = ADDTIME(NOW(), var_time_increment), price = price+var_price_increment, leader_id = var_leader_id, modified = NOW() WHERE id = var_auction_id AND closed = 0;
ELSE
UPDATE auctions SET end_time = ADDTIME(end_time, var_time_increment), price = price+var_price_increment, leader_id = var_leader_id, modified = NOW() WHERE id = var_auction_id AND closed = 0;
END IF;
Wouldn't this do the same as most of your code?:
UPDATE auctions SET
end_time = ADDTIME(GREATEST(end_time, NOW()), var_time_increment),
price = price+var_price_increment, leader_id = var_leader_id,
modified = NOW()
WHERE id = var_auction_id
AND closed = 0;
(or maybe it should be LEAST())