> In answer to your question, yes the index is used. You can see instructions > prefixed by Idx that aren't there when the index doesn't exist.
I just want to warn you: the index is used but not for finding appropriate value of col_c (as your question seem to imply). It is used only to find appropriate pair col_a, col_b and then SQLite will scan all values of col_c to satisfy your third condition. There's no way one can optimize searching rows satisfying some bitwise condition with use of an index. So if your query was like this: SELECT count(*) FROM table WHERE col_c & 32; and you had index on col_c then it wouldn't be used - whole table would be scanned. Pavel On Fri, Oct 9, 2009 at 4:42 AM, Roger Binns <[email protected]> wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Daniel Wickes wrote: >> I'm trying to optimise some of my queries, and I would like to know if >> bitwise operators in terms will still use an index, > > SQLite provides you the tools to find out for yourself. In the shell do > '.explain' and then give it your query prefixed with 'EXPLAIN'. You'll get > the virtual db engine code for the query printed out. > > This page gives a rough guide to vdbe code. (It does now use registers > rather than a stack.) > > http://www.sqlite.org/vdbe.html > > By far the easiest thing to do is explain a query you know uses the index > and then explain your query and look for the differences. > > In answer to your question, yes the index is used. You can see instructions > prefixed by Idx that aren't there when the index doesn't exist. > > Roger > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.9 (GNU/Linux) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org > > iEYEARECAAYFAkrO93oACgkQmOOfHg372QRXNQCeNSQ1r3o07Yj4n0RZ+kn9ePyT > cy8An05WyzhnU9M8Y3+00dFf4/tOh6vH > =hOpS > -----END PGP SIGNATURE----- > _______________________________________________ > sqlite-users mailing list > [email protected] > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > _______________________________________________ sqlite-users mailing list [email protected] http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

