pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Benjamin Krajmalnik <kraj@illumen.com>
To: pgsql-admin@postgresql.org
Subject: Tale partitioning
Date: Wed, 26 Apr 2006 11:50:12 -0600
Message-ID: <8511B4970E0D124898E973DF496F9B432515C3@stash.stackdump.local> (raw)

I have created a parent table and inherited into several tables to
facilitate table partitioning.

I noticed that the inherited tables did not inherit any of the indices,
etc. in their DDL.

Do these need to be created, or are they actually there via inheritance
but only "used" when the parent table is queried directly?

 

Also, I am having what appear to be some performance issues when
querying a large table which currently has about 1.8 million rows.

It may be an issue of me adjusting to gow PostgreSQL's planner works.

 

 

ksrawsysid is the primary key.  I expected it to perform very quickly,
yet it took about 90 seconds to return a recordset.

Adding a where clause made the query almost instantaneous.

 

The query which I issued was:

 

select * from tblksraw order by ksrawsysid desc limit 10

 

QUERY PLAN

Limit  (cost=5351703.70..5351703.72 rows=10 width=1186)

  ->  Sort  (cost=5351703.70..5355948.36 rows=1697865 width=1186)

        Sort Key: public.tblksraw.ksrawsysid

        ->  Result  (cost=0.00..108314.65 rows=1697865 width=1186)

              ->  Append  (cost=0.00..108314.65 rows=1697865 width=1186)

                    ->  Seq Scan on tblksraw  (cost=0.00..108187.45
rows=1697145 width=255)

                    ->  Seq Scan on tblksraw01 tblksraw
(cost=0.00..10.60 rows=60 width=1186)

                    ->  Seq Scan on tblksraw02 tblksraw
(cost=0.00..10.60 rows=60 width=1186)

                    ->  Seq Scan on tblksraw03 tblksraw
(cost=0.00..10.60 rows=60 width=1186)

                    ->  Seq Scan on tblksraw04 tblksraw
(cost=0.00..10.60 rows=60 width=1186)

                    ->  Seq Scan on tblksraw05 tblksraw
(cost=0.00..10.60 rows=60 width=1186)

                    ->  Seq Scan on tblksraw06 tblksraw
(cost=0.00..10.60 rows=60 width=1186)

                    ->  Seq Scan on tblksraw07 tblksraw
(cost=0.00..10.60 rows=60 width=1186)

                    ->  Seq Scan on tblksraw08 tblksraw
(cost=0.00..10.60 rows=60 width=1186)

                    ->  Seq Scan on tblksraw09 tblksraw
(cost=0.00..10.60 rows=60 width=1186)

                    ->  Seq Scan on tblksraw10 tblksraw
(cost=0.00..10.60 rows=60 width=1186)

                    ->  Seq Scan on tblksraw11 tblksraw
(cost=0.00..10.60 rows=60 width=1186)

                    ->  Seq Scan on tblksraw12 tblksraw
(cost=0.00..10.60 rows=60 width=1186)

 

ksrawsysid is the primary key.  I expected it to perform very quickly,
yet it took about 90 seconds to return a recordset.

Adding a where clause made the query almost instantaneous.

 

select * from tblksraw  where ksrawsysid between 1000000 and 1000020
order by ksrawsysid desc limit 10

 

 

 

QUERY PLAN

Limit  (cost=142.85..142.87 rows=10 width=1186)

  ->  Sort  (cost=142.85..142.93 rows=31 width=1186)

        Sort Key: public.tblksraw.ksrawsysid

        ->  Result  (cost=0.00..142.08 rows=31 width=1186)

              ->  Append  (cost=0.00..142.08 rows=31 width=1186)

                    ->  Index Scan using pk_tblksraw on tblksraw
(cost=0.00..11.28 rows=19 width=255)

                          Index Cond: ((ksrawsysid >= 1000000) AND
(ksrawsysid <= 1000020))

                    ->  Seq Scan on tblksraw01 tblksraw
(cost=0.00..10.90 rows=1 width=1186)

                          Filter: ((ksrawsysid >= 1000000) AND
(ksrawsysid <= 1000020))

                    ->  Seq Scan on tblksraw02 tblksraw
(cost=0.00..10.90 rows=1 width=1186)

                          Filter: ((ksrawsysid >= 1000000) AND
(ksrawsysid <= 1000020))

                    ->  Seq Scan on tblksraw03 tblksraw
(cost=0.00..10.90 rows=1 width=1186)

                          Filter: ((ksrawsysid >= 1000000) AND
(ksrawsysid <= 1000020))

                    ->  Seq Scan on tblksraw04 tblksraw
(cost=0.00..10.90 rows=1 width=1186)

                          Filter: ((ksrawsysid >= 1000000) AND
(ksrawsysid <= 1000020))

                    ->  Seq Scan on tblksraw05 tblksraw
(cost=0.00..10.90 rows=1 width=1186)

                          Filter: ((ksrawsysid >= 1000000) AND
(ksrawsysid <= 1000020))

                    ->  Seq Scan on tblksraw06 tblksraw
(cost=0.00..10.90 rows=1 width=1186)

                          Filter: ((ksrawsysid >= 1000000) AND
(ksrawsysid <= 1000020))

                    ->  Seq Scan on tblksraw07 tblksraw
(cost=0.00..10.90 rows=1 width=1186)

                          Filter: ((ksrawsysid >= 1000000) AND
(ksrawsysid <= 1000020))

                    ->  Seq Scan on tblksraw08 tblksraw
(cost=0.00..10.90 rows=1 width=1186)

                          Filter: ((ksrawsysid >= 1000000) AND
(ksrawsysid <= 1000020))

                    ->  Seq Scan on tblksraw09 tblksraw
(cost=0.00..10.90 rows=1 width=1186)

                          Filter: ((ksrawsysid >= 1000000) AND
(ksrawsysid <= 1000020))

                    ->  Seq Scan on tblksraw10 tblksraw
(cost=0.00..10.90 rows=1 width=1186)

                          Filter: ((ksrawsysid >= 1000000) AND
(ksrawsysid <= 1000020))

                    ->  Seq Scan on tblksraw11 tblksraw
(cost=0.00..10.90 rows=1 width=1186)

                          Filter: ((ksrawsysid >= 1000000) AND
(ksrawsysid <= 1000020))

                    ->  Seq Scan on tblksraw12 tblksraw
(cost=0.00..10.90 rows=1 width=1186)

                          Filter: ((ksrawsysid >= 1000000) AND
(ksrawsysid <= 1000020))

 

Form the query plans, it appears that I have to explicitly create
indices on the inherited tables. I would have assumed they would have
been inherited as well.

I expected that limiting the number of rows would have resulted in an
immediate result, whereas in actuality what appears to be happening is
that the entire table is being processed as a result set, but only 10
rows being returned.  This seems like extraneous.

 

Regards,

 

Benjamin

view thread (7+ messages)  latest in thread

Message-ID: <8511B4970E0D124898E973DF496F9B432515C3@stash.stackdump.local>
Permalink:  ../8511B4970E0D124898E973DF496F9B432515C3@stash.stackdump.local/
Also on:    postgresql.org/message-id/8511B4970E0D124898E973DF496F9B432515C3@stash.stackdump.local

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: kraj@illumen.com
  Subject: Re: Tale partitioning
  In-Reply-To: <8511B4970E0D124898E973DF496F9B432515C3@stash.stackdump.local>
  References: <8511B4970E0D124898E973DF496F9B432515C3@stash.stackdump.local>

* 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