Ian Hardingham <i...@omroth.com> wrote: > Would this index be enough: > > CREATE INDEX IF NOT EXISTS mtTablePlayer1 ON multiturnTable > (player1,player2) > > Or do I need the opposite as well? > > CREATE INDEX IF NOT EXISTS mtTablePlayer1 ON multiturnTable > (player2,player1)
For the queries you've shown, you only need one. > Why I have two queries: the order of the arguments are different - I am > looking for games where player1 is Ian and player2 is Igor, but I also > want games where player1 is Igor and player2 is Ian. Can't you use the same query, and just change the order of parameters? Is it significant which player is designated player1 and which player2 (e.g. like chess, where it's significant who played white and who played black)? If not, I'd consider picking a stable order (e.g., alphabetical on usernames) when inserting records into the table in the first place. So that, whenever a game between players A and B is recorded, A will always be player1 and B player2. Even if the order is significant, I'd still consider doing this, and recording in a separate field whether the order should be reversed. -- Igor Tandetnik _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users