Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UQj6N-0003Oy-H1 for pgsql-bugs@arkaria.postgresql.org; Fri, 12 Apr 2013 18:53:35 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UQj6N-0006df-1e for pgsql-bugs@arkaria.postgresql.org; Fri, 12 Apr 2013 18:53:35 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UQj6M-0006da-7J for pgsql-bugs@postgresql.org; Fri, 12 Apr 2013 18:53:34 +0000 Received: from hogranch.com ([75.101.82.47]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UQj6C-0007zW-40 for pgsql-bugs@postgresql.org; Fri, 12 Apr 2013 18:53:33 +0000 Received: from [192.168.0.2] (porker [192.168.0.2]) by hogranch.com (8.11.6/8.11.6) with ESMTP id r3CIrA928696 for ; Fri, 12 Apr 2013 11:53:10 -0700 Message-ID: <51685817.80104@hogranch.com> Date: Fri, 12 Apr 2013 11:53:11 -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: pgsql-bugs@postgresql.org Subject: Re: Partition performance causing ddl commands to slow down significantly References: <20130412114630.5a830134ae84016b0174832fdc1a3173.fc7948457c.wbe@email11.secureserver.net> In-Reply-To: <20130412114630.5a830134ae84016b0174832fdc1a3173.fc7948457c.wbe@email11.secureserver.net> Content-Type: multipart/alternative; boundary="------------080302090707060807090201" 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. --------------080302090707060807090201 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 4/12/2013 11:46 AM, fburgess@radiantblue.com wrote: > We are having performance related problems on one of our big data > Partition tables. The table is partitioned by date and the partitions > are organized from Jan 2003 thru Dec 2013. > We have 268 child partitions associated with the Parent table, and we > have constraint_exclusion=partition set. > The execution of the SQL query: select count(*) from dna_strands; > yields: QUERY PLAN > _____________________________________________________________________________________________ > > Aggregate (cost=2246778.49..2246778.50 rows=1 width=0) > -> Append (0.00..2159647.04 rows=34852580 width=0) > -> Seq Scan on dna_strands (cost=0.00..0.00 rows=1 width) > Filter: (cid = 1) > -> Index Scan using dna_strands_y2003m01_cid on > dna_strands_y2003m01 dna_strands (cost=0.00..677652 rows=1 width=0) > Index Cond: (cid = 1) > -> Index Scan using dna_strands_y2003m02_cid on > dna_strands_y2003m02 dna_strands (cost=0.00..974423 rows=1 width=0) > Index Cond: (cid = 1) > -> Index Scan using dna_strands_y2003m03_cid on > dna_strands_y2003m03 dna_strands (cost=0.00..992301 rows=1 width=0) > Index Cond: (cid = 1) > ... > ... > -> Index Scan using dna_strands_y2013m12_cid on > dna_strands_y2013m12 dna_strands (cost=0.00..8.27 rows=1 width=0) > Index Cond: (cid = 1) > Question: Is there any way to modify the Planner to do the inverse of > the Index Scan's. In other words, to start the index scans in reverse > order from > the most recent date to the oldest date, i.e. "dna_strands_y2013m12" > backwards. Our application users query much more heavily at the most > recent data that > has been ingested into the PostgreSQL database. Would this capability > speed up query performance? it wouldn't speed up your example, as your example has to scan every single row of the whole mess. not sure where Filter: (cid=1) comes from, since you showed the query as SELECT COUNT(*) FROM dna_strands; -- john r pierce 37N 122W somewhere on the middle of the left coast --------------080302090707060807090201 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by hogranch.com id r3CIrA928696
On 4/12/2013 11:46 AM, fburgess@radiantblue.com wrote:
We are having performance related problems on one of our big data Partition tables. The table is partitioned by date and the partitions are organized from Jan 2003 thru Dec 2013.
We have 268 child partitions associated with the Parent table, and we have constraint_exclusion=3Dpartition set.
The execution of the SQL query:=C2=A0 select count(*) from dna_strands;
yields:=C2=A0 QUERY PLAN
_______________________________________________________________= ______________________________=C2=A0=C2=A0
Aggregate (cost=3D2246778.49..2246778.50 rows=3D1 width=3D0)=
=C2=A0 -> Append (0.00..2159647.04 rows=3D34852580 width=3D0= )
=C2=A0=C2=A0=C2=A0=C2=A0 -> Seq Scan on dna_strands (cost=3D= 0.00..0.00 rows=3D1 width)
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 Filter: = (cid =3D 1)
=C2=A0=C2=A0=C2=A0=C2=A0 -> Index Scan using dna_strands_y20= 03m01_cid on dna_strands_y2003m01 dna_strands (cost=3D0.00..677652 rows=3D1 width=3D0)
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 In= dex Cond: (cid =3D 1)
=C2=A0=C2=A0=C2=A0=C2=A0 -> Index Scan using dna_strands_y20= 03m02_cid on dna_strands_y2003m02 dna_strands (cost=3D0.00..974423 rows=3D1 width=3D0)
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 In= dex Cond: (cid =3D 1)
=C2=A0=C2=A0=C2=A0=C2=A0 -> Index Scan using dna_strands_y20= 03m03_cid on dna_strands_y2003m03 dna_strands (cost=3D0.00..992301 rows=3D1 width=3D0)
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 In= dex Cond: (cid =3D 1)
=C2=A0=C2=A0=C2=A0=C2=A0 ...
=C2=A0=C2=A0=C2=A0=C2=A0 ...
=C2=A0=C2=A0=C2=A0=C2=A0 -> Index Scan using dna_strands_= y2013m12_cid on dna_strands_y2013m12 dna_strands (cost=3D0.00..8.27 rows=3D1 width=3D0)
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 In= dex Cond: (cid =3D 1)
Question: Is there any way to modify the Planner to do the inverse of the Index Scan's.=C2=A0 In other words, to start the index scans in reverse order from
the most recent date to the oldest date, i.e. "dna_strands_y2013m12" backwards. Our application users query much more heavily at the most recent data that
has been ingested into the PostgreSQL database.=C2=A0 Would thi= s capability speed up query performance?

it wouldn't speed up your example, as your example has to scan every single row of the whole mess.=C2=A0=C2=A0 not sure where Filter: (cid= =3D1) comes from, since you showed the query as SELECT COUNT(*) FROM dna_strands;


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