Seems the correct code is already generated...

asql> explain select rowid from x where 1=?;
addr  opcode         p1    p2    p3    p4             p5  comment
----  -------------  ----  ----  ----  -------------  --  -------------
0     Trace          0     0     0                    00  NULL
1     Integer        1     2     0                    00  NULL
2     Variable       1     3     0                    00  NULL
3     Eq             3     1     2                    72  NULL
4     IfNot          1     12    1                    00  NULL
5     Goto           0     14    0                    00  NULL
6     OpenRead       0     2     1     0              00  x
7     Rewind         0     12    0                    00  NULL
8     IfNot          1     11    1                    00  NULL
9     Rowid          0     4     0                    00  NULL
10    ResultRow      4     1     0                    00  NULL
11    Next           0     8     0                    01  NULL
12    Close          0     0     0                    00  NULL
13    Halt           0     0     0                    00  NULL
14    Transaction    1     0     0                    00  NULL
15    VerifyCookie   1     1     1                    00  NULL
16    TableLock      1     2     0     x              00  NULL
17    Goto           0     6     0                    00  NULL

-----Urspr?ngliche Nachricht-----
Von: Mark Lawrence [mailto:nomad at null.net]
Gesendet: Freitag, 12. Juni 2015 11:37
An: sqlite-users at mailinglists.sqlite.org
Betreff: [sqlite] Contstant WHERE terms still require table scan?

I'm wondering if it would be possible to optimize the query planner for 
situations where one of the WHERE clauses is a constant that evaluates to false?

    CREATE TABLE x(
        id INTEGER PRIMARY KEY
    );

    EXPLAIN QUERY PLAN SELECT
        x.id
    FROM
        x
    WHERE
        1=0
    ;

    -- selectid    order       from        detail
    -- ----------  ----------  ----------  ------------
    -- 0           0           0           SCAN TABLE x


This would potentially allow me to shortcut some largish UNION statements.

Mark.
--
Mark Lawrence
Home:   +41 44 520 12 59
Mobile: +41 76 796 65 68
_______________________________________________
sqlite-users mailing list
sqlite-users at mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


___________________________________________
 Gunter Hick
Software Engineer
Scientific Games International GmbH
FN 157284 a, HG Wien
Klitschgasse 2-4, A-1130 Vienna, Austria
Tel: +43 1 80100 0
E-Mail: hick at scigames.at

This communication (including any attachments) is intended for the use of the 
intended recipient(s) only and may contain information that is confidential, 
privileged or legally protected. Any unauthorized use or dissemination of this 
communication is strictly prohibited. If you have received this communication 
in error, please immediately notify the sender by return e-mail message and 
delete all copies of the original communication. Thank you for your cooperation.


Reply via email to