On 05/04/2011 08:58 PM, Schrum, Allan wrote: > Hi Folks, > > Using virtual tables the WHERE clause is broken up and sent to the "best > index" function to determine the best index. Then the "filter" function is > called to perform the actual work. I've noticed that the SQLITE engine seems > to process OR clauses outside of the virtual table process, while AND clauses > are provided to the "filter" function to use. How can we get the OR clauses > sent to the "filter" function where we can make use of that information? > > Using SQLITE 3.6.18.
If you do this: SELECT * FROM vtab WHERE a=1 OR b=2 Then SQLite will invoke xBestIndex once for each of the two conditions and once for a full-scan (no WHERE conditions at all). If it thinks there is advantage in doing so (based on the estimatedCost values returned by the three xBestIndex calls), SQLite may implement the query by using xFilter/xNext to get all the a=1 rows from the virtual table, then again for all of the b=2 rows. It uses the rowid values to avoid returning duplicates to the caller. It is not possible for SQLite to request a (a=1 OR b=2) with a single xFilter/xNext scan. _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users