Heikki and all,
I've got a quick question which may be more general sql related but
since I'm using innodb tables specifically for the row locking.

The following process description is specifically designed to prevent
duplicates.

My current process:
select * from run where job_id = 111 and thread_id = 0 limit 10000 for
update;

update run set thread_id = 999 where job_id = 111 and thread_id = 0 and
( rec_id = x or rec_id = x1 ... );  // rec_id pulled via loop of
previous select

select main.* from run,main where run.job_id = 111 and run.thread_id =
999 and run.rec_id = main.rec_id; // this is saved off

delete from run where job_id = 111 and thread_id = 999;

---- end ----
As you can see, it's quite a few queries to prevent collisions.  Right
now the update and delete take the longest for obvious reasons.

What I'm wondering is if I can do the following:

select main.* from run,main where run.job_id = 111 and run.thread_id = 0
and run.rec_id = main.rec_id limit 10000 for update;

delete from run where job_id = 111 and (rec_id = x or rec_id = x2 ...);

unlock tables;


Will the above 2 queries + unlock tables be as safe as the previous 4
queries that take so much longer?

Thanks for your help and very nice table handler.

Mike...



---------------------------------------------------------------------
Before posting, please check:
  http://www.mysql.com/manual.php   (the manual)
  http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to