Incorrect explain query plan print

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Incorrect explain query plan print

korablev
CREATE TABLE t1(a PRIMARY KEY, b, c) WITHOUT ROWID;
INSERT INTO t1 VALUES(1, 1, 1);
EXPLAIN QUERY PLAN SELECT min(c) FROM t1;

This query emits: "SEARCH TABLE t1 USING PRIMARY KEY". However, it is not
really SEARCH, but SCAN TABLE. It can be seen from opcodes for VM. (Indeed,
we should traverse through all table to find min value of "c" column)

The problem seems to be in sqlite3WhereExplainOneScan() function:

isSearch = (flags & (WHERE_BTM_LIMIT | WHERE_TOP_LIMIT)) != 0
                    || (pLoop->nEq > 0)
                    || (wctrlFlags & (WHERE_ORDERBY_MIN | WHERE_ORDERBY_MAX));

Query uses min function, so flag WHERE_ORDERBY_MIN is set.

Is this considered to be a bug?




--
Sent from: http://sqlite.1065341.n5.nabble.com/
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Incorrect explain query plan print

korablev
Any thoughts concerning this issue? This output is really confusing when
trying to understand query plan...



--
Sent from: http://sqlite.1065341.n5.nabble.com/
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users