Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UQjup-00077R-P2 for pgsql-bugs@arkaria.postgresql.org; Fri, 12 Apr 2013 19:45:43 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UQjup-0005bU-8j for pgsql-bugs@arkaria.postgresql.org; Fri, 12 Apr 2013 19:45:43 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UQjuo-0005bO-Bj for pgsql-bugs@postgresql.org; Fri, 12 Apr 2013 19:45:42 +0000 Received: from hogranch.com ([75.101.82.47]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UQjug-0007o6-C7 for pgsql-bugs@postgresql.org; Fri, 12 Apr 2013 19:45:42 +0000 Received: from [192.168.0.2] (porker [192.168.0.2]) by hogranch.com (8.11.6/8.11.6) with ESMTP id r3CJjK929665; Fri, 12 Apr 2013 12:45:20 -0700 Message-ID: <51686451.2010501@hogranch.com> Date: Fri, 12 Apr 2013 12:45:21 -0700 From: John R Pierce User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:17.0) Gecko/20130328 Thunderbird/17.0.5 MIME-Version: 1.0 To: fburgess@radiantblue.com CC: pgsql-bugs@postgresql.org Subject: Re: Partition performance causing ddl commands to slow down significantly References: <20130412121002.5a830134ae84016b0174832fdc1a3173.1349262d35.wbe@email11.secureserver.net> In-Reply-To: <20130412121002.5a830134ae84016b0174832fdc1a3173.1349262d35.wbe@email11.secureserver.net> Content-Type: multipart/alternative; boundary="------------040401060008070104030209" X-HawgScanner-Information: Please contact the ISP for more information X-HawgScanner: Found to be clean X-Pg-Spam-Score: -4.3 (----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org This is a multi-part message in MIME format. --------------040401060008070104030209 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 4/12/2013 12:10 PM, fburgess@radiantblue.com wrote: > The SQL query should be: select count(*) from dna_strands where cid = 1; ah. I suspected as much. its so hard to analyze problems with incorrect information and so easy to make wrong assumptions. > I just realize don't think this is not going to work. if for the sake > of argument that cid = 1 is much more likely be be found in a more > recent partition, any inverse search mechanism in the planner will > find that match first but then continue through all of the other > partitions, Right? The only way to optimize this is to find some way > of adding the partition key date to the where clause. yeah, pretty much. all partitions HAVE to be scanned in case there's a row with that condition, there's no way of avoiding that. and yeah, abstraction layers like Hibernate make things even harder to manage btw, I think you said 268 child partitions. that is, in my experience, way too many. we try and keep partitions under a few dozen even on our multi-terabyte tables. 6 months by week is about as far as we go. with your 10 year data, I'd probably partition by quarter, or something. -- john r pierce 37N 122W somewhere on the middle of the left coast --------------040401060008070104030209 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by hogranch.com id r3CJjK929665
On 4/12/2013 12:10 PM, fburgess@radiantblue.com wrote:
The SQL query should be: select count(*) from dna_strands where cid =3D 1;

ah.=C2=A0 I suspected as much.=C2=A0=C2=A0=C2=A0 its so hard to analy= ze problems with incorrect information and so easy to make wrong assumptions.

=C2=A0
I=C2=A0 just realize don't think this is not going to work. = if for the=C2=A0sake of argument that cid =3D 1 is much more likel= y be be found in a more recent partition,=C2=A0any inverse search mechanism in the planner will find that match first but then continue through all of the other partitions, Right? The only way to optimize this is to find some way of adding the partition key date to the where clause.

yeah, pretty much.=C2=A0=C2=A0 all partitions HAVE to be scanned in c= ase there's a row with that condition, there's no way of avoiding that.
and yeah, abstraction layers like Hibernate make things even harder to manage

btw, I think you said 268 child partitions.=C2=A0 that is, in my experience, way too many.=C2=A0=C2=A0 we try and keep partitions unde= r a few dozen even on our multi-terabyte tables.=C2=A0=C2=A0 6 months by week= is about as far as we go.=C2=A0 with your 10 year data, I'd probably partition= by quarter, or something.



--=20
john r pierce                                      37N 122W
somewhere on the middle of the left coast
--------------040401060008070104030209--