On 1/23/2013 11:22 PM, Richard Baron Penman wrote:
And then I process it like this, N keys at a time:
SELECT key FROM queue WHERE status=0 LIMIT N;
BEGIN TRANSACTION;
for key in keys:
UPDATE queue SET status=1 WHERE key=key;
END TRANSACTION;
How can this SELECT and UPDATE be combined more efficiently?
Something like this perhaps:
update queue set status = 1 where status = 0 and key <
(select key from queue where status=0 order by key limit 1 offset N);
--
Igor Tandetnik
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users