Re: [PERFORM] Query planner not using indexes with JOIN query and OR clause

2015-07-14 Thread Ben Hoyt
> > Try refactoring to: > > select ai.position, i.filename as image_filename, p.filename as > panorama_filename > from album_items ai > left join image2 i on i.imageid = ai.image_id > left join panoramas p on p.id = ai.panorama_id > where i.filename in ('pano360--v471.jpg', 'pano360-2--v474.jpg') >

Re: [PERFORM] Query planner not using indexes with JOIN query and OR clause

2015-07-14 Thread Merlin Moncure
On Mon, Jul 13, 2015 at 4:01 PM, Merlin Moncure wrote: > On Mon, Jul 13, 2015 at 3:54 PM, Ben Hoyt wrote: >> Hi folks, >> >> I have a fairly simple three-table query (pasted below) with two LEFT JOINs >> and an OR in the WHERE clause that for some reason is doing sequential scans >> on all three

Re: [PERFORM] Query planner not using indexes with JOIN query and OR clause

2015-07-13 Thread Merlin Moncure
On Mon, Jul 13, 2015 at 3:54 PM, Ben Hoyt wrote: > Hi folks, > > I have a fairly simple three-table query (pasted below) with two LEFT JOINs > and an OR in the WHERE clause that for some reason is doing sequential scans > on all three tables (two of them large -- several million rows), even though

[PERFORM] Query planner not using indexes with JOIN query and OR clause

2015-07-13 Thread Ben Hoyt
Hi folks, I have a fairly simple three-table query (pasted below) with two LEFT JOINs and an OR in the WHERE clause that for some reason is doing sequential scans on all three tables (two of them large -- several million rows), even though I have indexes on the relevant "filename" columns. Note t