[sqlite] SQLite scans the largest table in the query where a very small table is available

2016-01-20 Thread Matthias-Christian Ott
On 2016-01-20 18:14, Yuri wrote: > Does SQLite optimizer look at the row counts? (I think it does because > the plans are different when there are no rows present). > How to correct the problem? If you want to do a manual optimization, the following describes how to set the order of joins

[sqlite] SQLite scans the largest table in the query where a very small table is available

2016-01-20 Thread Hick Gunter
Have you tried running ANALYZE on a representative dataset? This will determine the "shape" of your tables and allow the query planner to make better guesses of the costs associated with each join. If, after ANALYZE, you still feel the need to improve over the query planners' ordering, you can

[sqlite] SQLite scans the largest table in the query where a very small table is available

2016-01-20 Thread Richard Hipp
On 1/20/16, Yuri wrote: > > Does SQLite optimizer look at the row counts? It does if they are available. Run ANALYZE to generate the row counts. -- D. Richard Hipp drh at sqlite.org

[sqlite] SQLite scans the largest table in the query where a very small table is available

2016-01-20 Thread Yuri
On 01/20/2016 09:21, Hick Gunter wrote: > ave you tried running ANALYZE on a representative dataset? This will > determine the "shape" of your tables and allow the query planner to make > better guesses of the costs associated with each join. > > If, after ANALYZE, you still feel the need to

[sqlite] SQLite scans the largest table in the query where a very small table is available

2016-01-20 Thread Yuri
I have the select query over the linked chain of tables with all needed indices present. All but one tables (m,h,e,w) have row count ~300,000-700,000, mt table has only ~150 rows. Obviously, based on the row count, scan should begin from the table mt. However, SQLite actually scans beginning