Re: [sqlite] vtable vs. OR condition

2014-05-26 Thread Dan Kennedy

On 05/26/2014 01:45 AM, András Kardos wrote:

Hello,

As an expoeriment I'd like to create various virtual tables (vtable) for
SQLite. Like filysystem, process list, mailbox - all local or remote. The
idea is to use SQLite as an unified API and query processor to access or
join data from various sources. I read an old old article in Dr. Dobbs (
http://goo.gl/khg1pN), and it mentions an issue with OR conditions vs.
virtual tables, that is if a query has theese, than the filter conditions
will not be passed to the xBestIndex call, and thus will not be passed to
xFilter, and thus access to the virtual table will always be done as table
scan, and that is quite inefficient. Rewriting queries is not an option as
the article suggest, as that would force users to an unusual SQL style just
to make things faster. Are there any advancements in this topic?


It's no longer true. If you issue a query like:

  SELECT * FROM vtab WHERE vtab.a=? OR vtab.b=?

then SQLite makes separate calls to xBestIndex for (vtab.a=?) and 
(vtab.b=?). If the virtual table implementation reports that both of 
these can be performed efficiently, SQLite makes two separate sets of 
calls to xFilter/xStep (one for each vtab.*=? condition) and merges the 
results before returning them to the caller.


Dan.








  Any
experiences with this issue? Or any suggestions for other query processing
engines I might use?

Thanks,
Andris
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


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


[sqlite] vtable vs. OR condition

2014-05-25 Thread András Kardos
Hello,

As an expoeriment I'd like to create various virtual tables (vtable) for
SQLite. Like filysystem, process list, mailbox - all local or remote. The
idea is to use SQLite as an unified API and query processor to access or
join data from various sources. I read an old old article in Dr. Dobbs (
http://goo.gl/khg1pN), and it mentions an issue with OR conditions vs.
virtual tables, that is if a query has theese, than the filter conditions
will not be passed to the xBestIndex call, and thus will not be passed to
xFilter, and thus access to the virtual table will always be done as table
scan, and that is quite inefficient. Rewriting queries is not an option as
the article suggest, as that would force users to an unusual SQL style just
to make things faster. Are there any advancements in this topic? Any
experiences with this issue? Or any suggestions for other query processing
engines I might use?

Thanks,
Andris
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users