Re: [sqlite] How does adding an index change a query plan even though the new query plan doesn't use the newly added index?

2018-02-19 Thread Jens Alfke
> On Feb 15, 2018, at 3:31 PM, David Pitchford > wrote: > > I have been using SQLite 3.8.2 > for this since I don't feel up to try replacing the version that came with > my OS. If you're coding in some dialect of C, simply download the 'amalgamation' (the big sqlite3.c and sqlite3.h files)

Re: [sqlite] How does adding an index change a query plan even though the new query plan doesn't use the newly added index?

2018-02-16 Thread Dan Kennedy
On 02/16/2018 06:31 AM, David Pitchford wrote: I've almost finished debugging an issue in which a certain query was taking drastically longer for some versions of a database (a music library file) than for other, similarly sized versions. I have been using SQLite 3.8.2 for this since I don't feel

Re: [sqlite] How does adding an index change a query plan even though the new query plan doesn't use the newly added index?

2018-02-16 Thread Simon Slavin
On 15 Feb 2018, at 11:31pm, David Pitchford wrote: > So I'm wondering not just for this query, but in general, how can adding an > index cause a query plan to change even if the new query plan doesn't make > use of the new index? After creating indexes and entering plausible data (in any order

Re: [sqlite] How does adding an index change a query plan even though the new query plan doesn't use the newly added index?

2018-02-16 Thread Dominique Devienne
On Fri, Feb 16, 2018 at 6:07 PM, David Raymond wrote: > Remember that the usefulness of an index depends on the ordering of the > fields. An index on (b, a) isn't useful if you're looking for a, it's only useful > if you're looking for b. > Sometimes it is. See https://sqlite.org/optoverview.ht

Re: [sqlite] How does adding an index change a query plan even though the new query plan doesn't use the newly added index?

2018-02-16 Thread David Raymond
A little hard to debug without the actual schema. You're giving us the query with a, b, c etc but the query plan with the real names. The slow plan is using an automatic index on CoreCache (ModelID), ie it's making a new index when it runs and then dumping the index at the end of the query. Tha