pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rural Hunter <ruralhunter@gmail.com>
To: pgsql-performance@postgresql.org
Subject: Very slow planning performance on partition table
Date: Wed, 23 Jul 2014 21:21:00 +0800
Message-ID: <53CFB6BC.4050606@gmail.com> (raw)
List-Unsubscribe:  <mailto:majordomo@postgresql.org?body=unsub%20pgsql-performance>

Hi,

I have a table partitioned with about 60 children tables.  Now I found 
the planning time of simple query with partition key are very slow.
# explain analyze select count(*) as cnt from article where pid=88 and 
hash_code='2ca3ff8b17b163f0212c2ba01b80a064';
QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------------------------
  Aggregate  (cost=16.55..16.56 rows=1 width=0) (actual 
time=0.259..0.259 rows=1 loops=1)
    ->  Append  (cost=0.00..16.55 rows=2 width=0) (actual 
time=0.248..0.250 rows=1 loops=1)
          ->  Seq Scan on article  (cost=0.00..0.00 rows=1 width=0) 
(actual time=0.002..0.002 rows=0 loops=1)
                Filter: ((pid = 88) AND (hash_code = 
'2ca3ff8b17b163f0212c2ba01b80a064'::bpchar))
          ->  Index Scan using article_88_hash_idx on article_88 
article  (cost=0.00..16.55 rows=1 width=0) (actual time=0.246..0.248 
rows=1 loops=1)
                Index Cond: (hash_code = 
'2ca3ff8b17b163f0212c2ba01b80a064'::bpchar)
                Filter: (pid = 88)
  Total runtime: 3.816 ms
(8 rows)

Time: 30999.986 ms

You can see the timing output that the actual run time of the 'explain 
analyze' is 30 seconds while the select sql itself takes only 3 ms. My 
partition key is on article.pid and the constraint is simple like this: 
CONSTRAINT article_88_pid_check CHECK (pid = 88). What's wrong and how 
can I improve the planning performance?


-- 
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance



view thread (21+ messages)  latest in thread

Message-ID: <53CFB6BC.4050606@gmail.com>
Permalink:  ../53CFB6BC.4050606@gmail.com/
Also on:    postgresql.org/message-id/53CFB6BC.4050606@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: ruralhunter@gmail.com
  Subject: Re: Very slow planning performance on partition table
  In-Reply-To: <53CFB6BC.4050606@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox