MySQL Insert Query Randomly Takes a Long Time

Posted by ShimmerTroll on Stack Overflow See other posts from Stack Overflow or by ShimmerTroll
Published on 2010-06-05T02:49:34Z Indexed on 2010/06/05 21:32 UTC
Read the original article Hit count: 127

Filed under:
|
|
|
|

I am using MySQL to manage session data for my PHP application. When testing the app, it is usually very quick and responsive. However, seemingly randomly the response will stall before finally completing after a few seconds. I have narrowed the problem down to the session write query which looks something like this:

INSERT INTO Session VALUES('lvg0p9peb1vd55tue9nvh460a7', '1275704013', '') ON DUPLICATE KEY UPDATE sessAccess='1275704013',sessData='';

The slow query log has this information:

Query_time: 0.524446  Lock_time: 0.000046 Rows_sent: 0  Rows_examined: 0

This happens about 1 out of every 10 times. The query usually only takes ~0.0044 sec.

The table is InnoDB with about 60 rows. sessId is the primary key with a BTREE index.

Since this is accessed on every page view, it is clearly not an acceptable execution time. Why is this happening?

Update: Table schema is: sessId:varchar(32), sessAccess:int(10), sessData:text

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql