On 16 Dec 2009, at 5:32pm, Robert Citek wrote:

> I can adjust the table to pick 6 random players by including
> another column that holds a random integer:
> 
> $ sqlite3 -init <( echo '
> alter table pool add tag INTEGER
> ;
> update pool set tag=random()

After that UPDATE (that should be faster than before) create an INDEX on the 
'tag' column.  It will allow the next SELECT to operate faster.  Or perhaps the 
INDEX should be on 'team,tag'.

select team, player from pool p1 where rowid in (
 select rowid from pool p2 where
 p1.team=p2.team
 order by tag
 limit 6
 )
limit 10

Instead of this it might be faster to use the 'tag' column in another UPDATE 
command to set another field to which team each player should be on.  But I 
must admit that I can't figure out how to phrase the UPDATE command.

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

Reply via email to