Re: [PERFORM] Poor plan when joining against a union containing a join

2013-03-06 Thread Tom Lane
Josh Berkus writes: > On 03/06/2013 06:54 AM, David Leverton wrote: >> I'm encountering very poor query plans when joining against a union, > Actually, in case #4, Postgres *is* pushing down the join qual into the > segments of the Union. Yeah, but not further. I believe the core issue here (as

Re: [PERFORM] Poor plan when joining against a union containing a join

2013-03-06 Thread Josh Berkus
On 03/06/2013 06:54 AM, David Leverton wrote: > Hi all, > > I'm encountering very poor query plans when joining against a union, > where one branch of the union is itself a join: specifically, Postgres > does the entire inside join and then filters the result, rather than > pushing the filters dow

Re: [PERFORM] Optimize SELECT * from table WHERE foreign_key_id IN (key1,key2,key3,key4...)

2013-03-06 Thread Jeff Janes
On Tue, Mar 5, 2013 at 4:07 PM, Joshua D. Drake wrote: > > On 03/05/2013 03:51 PM, Niels Kristian Schjødt wrote: > > 3ms isn't slow >>> >>> Sorry, it's 3323ms! >> >> Can I do anything to optimize that query or maybe the index or something? >>> >>> your index is already used >>> >> >> Okay

[PERFORM] Poor plan when joining against a union containing a join

2013-03-06 Thread David Leverton
Hi all, I'm encountering very poor query plans when joining against a union, where one branch of the union is itself a join: specifically, Postgres does the entire inside join and then filters the result, rather than pushing the filters down to the joined tables. I've provided a standalone test c

Re: [PERFORM] Optimize SELECT * from table WHERE foreign_key_id IN (key1,key2,key3,key4...)

2013-03-06 Thread Julien Cigar
On 03/06/2013 00:51, Niels Kristian Schjødt wrote: Hi, thanks for answering. See comments inline. Den 05/03/2013 kl. 15.26 skrev Julien Cigar : On 03/05/2013 15:00, Niels Kristian Schjødt wrote: Hi, I'm running a rails app, where I have a model called Car that has_many Images. Now when I te