[UPHPU] MySQL Locking Question

Ray Hunter bigdog at venticon.com
Tue Aug 7 14:29:10 MDT 2007

> I have a question for any MySQL pros out there.  I am using a custom
> session_handler built in PHP.  The table is built on MyISAM engine.  These
> queries are locking up the table as they occur creating some slowness on the
> site.
> SELECT session_id, session_array FROM session_table WHERE
> session_key='keygoeshere' limit 0,1
> DELETE FROM session_table WHERE
> (UNIX_TIMESTAMP(now())-UNIX_TIMESTAMP(session_date_created))>86400
> Can I reconstruct these queries to not lock the table.  I understand when
> creating/updating the table it needs to lock, but I am under the assumption
> that for select and delete it does not need to lock?

here are some suggestions:

1. fine tune your select statement adding indexes (check summary tables)
2. try a sql buffer for your select statements
3. use a lower priority on the deletes
4. try adding a limit to delete query
5. perhaps look at bdb engine type or innodb for session_table


More information about the UPHPU mailing list