title: Ignore MySQL query if table is locked
body: <p>I have a cronjob that executes a MySQL query every few minutes, summarizing a large amount of rows in a MyISAM table. However, if this table is locked for a few minutes then these summary queries will pile up, so that even when the table is finally available again they will block it for a long time.</p>
  
  <p>None of these queries are essential, so I am happy with them failing from time to time. Thus, I would prefer it if these queries just failed if the table is blocked for more than a second or two.</p>
  
  <p>Is there a way to submit a query to MySQL that automatically gets killed if it waits for more than a few seconds for the table lock? Can I somehow mark the query as unimportant?</p>