Re: [GENERAL] WHERE IN (subselect) versus WHERE IN (1,2,3,)

2012-03-20 Thread Tom Lane
Kevin Goess writes: > Thanks for looking into it, Tom. We're using 9.0.4, so that might indeed > be the problem. What additional data (if any) would you like to see? Well, the first thing to do is update to 9.0.latest and see if the plan changes. There are plenty of good reasons to do that besi

Re: [GENERAL] WHERE IN (subselect) versus WHERE IN (1,2,3,)

2012-03-20 Thread Kevin Goess
Thanks for looking into it, Tom. We're using 9.0.4, so that might indeed be the problem. What additional data (if any) would you like to see? If you want to look into it further, I can give you schema, though I hesitate to spam the whole list. I could also mock up some tables and see what's the

Re: [GENERAL] WHERE IN (subselect) versus WHERE IN (1,2,3,)

2012-03-19 Thread Tom Lane
I wrote: > You've still got a nasty join-size estimation error: >> -> Nested Loop (cost=6.18..1939.43 rows=411736 width=8) (actual >> time=0.203..3.487 rows=35 loops=1) > It's not apparent why that's so far off ... What PG version is this, anyway? It strikes me that this estimation error migh

Re: [GENERAL] WHERE IN (subselect) versus WHERE IN (1,2,3,)

2012-03-19 Thread Tom Lane
Kevin Goess writes: > On Mon, Mar 19, 2012 at 9:24 AM, Albe Laurenz wrote: >> That means that your statistics are not accurate. > Aha, thanks, that explains why my test table with one row was so bad. But > even with all freshly ANALYZE'd tables, I still see the query reverting to > a sequential

Re: [GENERAL] WHERE IN (subselect) versus WHERE IN (1,2,3,)

2012-03-19 Thread Kevin Goess
On Mon, Mar 19, 2012 at 9:24 AM, Albe Laurenz wrote: > That means that your statistics are not accurate. > > As a first measure, you should ANALYZE the tables involved and see if > the problem persists. If yes, post the new plans. > Aha, thanks, that explains why my test table with one row was s

Re: [GENERAL] WHERE IN (subselect) versus WHERE IN (1,2,3,)

2012-03-19 Thread Albe Laurenz
Kevin Goess wrote: > We have a table "contexts" with 1.6 million rows, and a table "articles" with 1.4 million rows, where > an "article" is a particular kind of "context". We want to select from a join on those two tables > like this > > SELECT COUNT(*) > FROM contexts > JOIN article

[GENERAL] WHERE IN (subselect) versus WHERE IN (1,2,3,)

2012-03-15 Thread Kevin Goess
My apologies, I'm sure this question has been asked before but I couldn't find anything on the list that meant anything to me. We have a table "contexts" with 1.6 million rows, and a table "articles" with 1.4 million rows, where an "article" is a particular kind of "context". We want to select fr