List:General Discussion« Previous MessageNext Message »
From:Tim Gustafson Date:June 25 2010 11:14pm
Subject:Re: selecting data for computation
View as plain text  
> That shouldn't happen, since get_lock() will only succeed for one mysql
> connection at a time.

I figured it out.

Because there was an order by clause, the get_lock function was being
called for each row in the result set, and since each call to get_lock
releases any previous locks you had, mySQL was effectively locking and
then immediately unlocking (during the sort) each row in the result set.

I wound up moving the get_lock call into a second query, like this:

set i = 0;

select * from foo order by blah limit i, 1;

and then:

select get_lock(blah, 0);

and if that returns 0, do the processing, otherwise do:

i = i + 1; continue;

and that seems to be working like a charm now.

Thanks for your help!

Tim Gustafson

selecting data for computationTim Gustafson24 Jun
  • Re: selecting data for computationDan Nelson24 Jun
    • Re: selecting data for computationTim Gustafson25 Jun
      • Re: selecting data for computationTim Gustafson25 Jun
        • Re: selecting data for computationDan Nelson25 Jun
          • Re: selecting data for computationTim Gustafson26 Jun
            • Re: selecting data for computationBaron Schwartz28 Jun
              • Re: selecting data for computationTim Gustafson1 Jul
      • Re: selecting data for computationJoerg Bruehe25 Jun