Re: [sqlite] Query planner: Covering index not chosen over primary key

2019-05-03 Thread Jen Pollock
Thank you for the suggestion! The actual schema & query are a good deal more complicated, and I'm not looking for general optimization help with them right now. Jen Pollock On Fri, May 03, 2019 at 10:11:04PM +0100, Simon Slavin wrote: > On 3 May 2019, at 9:34pm, Jen Pollock wrote: > > >

Re: [sqlite] Query planner: Covering index not chosen over primary key

2019-05-03 Thread Simon Slavin
On 3 May 2019, at 9:34pm, Jen Pollock wrote: > SELECT filename > FROM images >JOIN embedded_files ON images.file_id == embedded_files.id > WHERE type == 'png'; Try this: CREATE INDEX images (type, file_id); ANALYZE; ___ sqlite-users mailing

Re: [sqlite] Query planner: Covering index not chosen over primary key

2019-05-03 Thread Richard Hipp
On 5/3/19, Jen Pollock wrote: > I assume the problem here is that the primary key is usually a weird > thing to index. I can definitely work around this, but I thought it > might be worth reporting as something that could perhaps be improved in > the query planner. Thank you. I have your

[sqlite] Query planner: Covering index not chosen over primary key

2019-05-03 Thread Jen Pollock
I have a database with a schema roughly like this: CREATE TABLE embedded_files( id INTEGER PRIMARY KEY, filename TEXT, data BLOB ); CREATE TABLE images( id INTEGER PRIMARY KEY, file_id INTEGER, type TEXT, FOREIGN KEY(file_id) REFERENCES embedded_files(id) );