Skip site navigation (1) Skip section navigation (2)

Re: Strange explain on partitioned tables

From: Greg Smith <greg(at)2ndquadrant(dot)com>
To: Philippe Rimbault <primbault(at)edd(dot)fr>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Strange explain on partitioned tables
Date: 2010-07-22 13:32:36
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-performance
Philippe Rimbault wrote:
> I have one thousand inherited tables like this one (with a different 
> check constraint on each) :

The PostgreSQL partitioning system is aimed to support perhaps a hundred 
inherited tables.  You can expect to get poor performance on queries if 
you create 1000 of them.  That's not the cause of your current problem, 
just pointing out there's a larger design problem here you'll probably 
have to fix one day.

>     select
>         documents.num,
>     from
>         documents,
>         locations l,
>         sources
>     where
>         documents.id_source = 113 and
> and
>     order by
> desc
>     limit 5;

Please don't put your EXPLAIN plans surrounded in " marks; it makes it 
harder to copy out of your message to analyze them with tools.  I put 
this bad one into and it notes that the 
"public.documents.id_location =" search is underestimating the 
number of rows by a factor of 8.7.  You might get a better plan if you 
can get better table statistics on that column.  Did you run ANALYZE 
since the partitioning was done?  If not, that could be making this 
worse.  You might increase the amount of table statistics on this 
specific column too, not sure what would help without knowing exactly 
what's in there.

Another thing you can try is suggest the optimizer not use a hash join 
here and see if it does the right thing instead; be a useful bit of 
feedback to see what that plan turns out to be.  Just put "set 
enable_hashjoin=off;" before the rest of the query, it will only impact 
that session.

Greg Smith  2ndQuadrant US  Baltimore, MD
PostgreSQL Training, Services and Support

In response to


pgsql-performance by date

Next:From: Philippe RimbaultDate: 2010-07-22 14:10:51
Subject: Re: Strange explain on partitioned tables
Previous:From: Philippe RimbaultDate: 2010-07-22 10:03:12
Subject: Re: Strange explain on partitioned tables

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group