Keith Medcalf, on Monday, September 16, 2019 01:33 PM, wrote... > > It will, but that depends how many rows there are. > > That is, the statement: SELECT * FROM t1 WHERE id IN (1,2,3,4,5,6) > > Is equivalent to > > CREATE TEMPORARY TABLE keyset (key PRIMARY KEY); > INSERT OR IGNORE INTO keyset VALUES (1), (2), (3), (4), (5), (6); > SELECT * FROM t1 WHERE id IN keyset; > DROP TABLE keyset; > > without the overhead of parsing the extra create/insert/drop statements. > And of course the part: > > SELECT * FROM t1 WHERE id IN keyset; > > is really > > SELECT * FROM t1 JOIN keyset ON t1.id == keyset.key; > > which is just sugar for: > > SELECT * FROM t1, keyset where t1.id == keyset.key; > > That means that the query planner may place the keyset in the outer loop, > or it may place t1 in the outer loop, depending on which is "better" and > what else the query is doing. In other words the list (...) just becomes > an index containing the values that is subsequently treated as a table (and > for that purpose the list (1,3,5,7,9) is the same as list > (9,1,7,3,5,1,9,3,7) -- since it is sorted and unique). Note that the list > may contain NULLs but they are ignored.
Wow! I learned a tone in this beauty! Saving it! :-) josé Thanks _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users