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
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to