On 9 Sep 2011, at 1:47pm, Ian Hardingham wrote:

> I really want O(1), but selecting by elo DESC and then setting a ranking 
> column for all records seems to be very slow, even during a transaction.  Any 
> tips for doing that fast?

If you're trying to collect this information for many different records there 
no need to run that SELECT many times.  Simply read your records ORDER BY old 
DESC and the first record will be ranked first, the second will be ranked 
second, etc..  There's no need to make SQLite do the numbering for you.

If you need to store the ranking with the record, just read all the rowids into 
a big array, then use their position in the array to work out how to update the 
ranking fields.

Also, you need to decide whether there's any point in storing these scores, or 
you can just calculate the score for a record when someone wants to see that 
particular record.

Simon.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to