pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: legrand legrand <legrand_legrand@hotmail.com>
To: pgsql-general@postgresql.org
Subject: Re: Questions about Partitioned Tables and Indexes
Date: Wed, 2 Oct 2019 15:37:27 -0700 (MST)
Message-ID: <1570055847573-0.post@n3.nabble.com> (raw)
In-Reply-To: <CADs92_+KSWg7=N70upjxs7E272MD6RANskbAftcNvZT6146D5g@mail.gmail.com>
References: <CADs92_+KSWg7=N70upjxs7E272MD6RANskbAftcNvZT6146D5g@mail.gmail.com>

Hi,

what you proposed seems correct to me.
I don't know how to list indexes from a partitionned index.

You can check if your indexes are valid using:

   select i.relname as indexname,i.relkind, t.relname as tablename,
t.relkind, idx.indisvalid
    from pg_class i
    join pg_index idx on idx.indexrelid = i.oid
    join pg_class t on t.oid = idx.indrelid
    where t.relname like 'test%'


to be really sure, try EXPLAIN with statements that should use those indexes
like

postgres=# explain select * from test_part where date_key >0;
                                      QUERY PLAN
---------------------------------------------------------------------------------------
 Append  (cost=6.53..43.80 rows=614 width=60)
   ->  Bitmap Heap Scan on test_201908  (cost=6.53..20.37 rows=307 width=60)
         Recheck Cond: (date_key > '0'::numeric)
         ->  Bitmap Index Scan on test_201908_pkey  (cost=0.00..6.45
rows=307 width=0)
               Index Cond: (date_key > '0'::numeric)
   ->  Bitmap Heap Scan on test_201909  (cost=6.53..20.37 rows=307 width=60)
         Recheck Cond: (date_key > '0'::numeric)
         ->  Bitmap Index Scan on test_201909_pkey  (cost=0.00..6.45
rows=307 width=0)
               Index Cond: (date_key > '0'::numeric)
(9 rows)

or

postgres=# explain select * from test_part where metric >0;
                                         QUERY PLAN
---------------------------------------------------------------------------------------------
 Append  (cost=6.53..43.80 rows=614 width=60)
   ->  Bitmap Heap Scan on test_201908  (cost=6.53..20.37 rows=307 width=60)
         Recheck Cond: (metric > '0'::numeric)
         ->  Bitmap Index Scan on test_idx1_201908  (cost=0.00..6.45
rows=307 width=0)
               Index Cond: (metric > '0'::numeric)
   ->  Bitmap Heap Scan on test_201909  (cost=6.53..20.37 rows=307 width=60)
         Recheck Cond: (metric > '0'::numeric)
         ->  Bitmap Index Scan on test_201909_metric_idx  (cost=0.00..6.45
rows=307 width=0)
               Index Cond: (metric > '0'::numeric)
(9 rows)

Regards
PAscal



--
Sent from: https://www.postgresql-archive.org/PostgreSQL-general-f1843780.html





view thread (2+ messages)

Message-ID: <1570055847573-0.post@n3.nabble.com>
Permalink:  ../1570055847573-0.post@n3.nabble.com/
Also on:    postgresql.org/message-id/1570055847573-0.post@n3.nabble.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 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-general@postgresql.org
  Cc: legrand_legrand@hotmail.com
  Subject: Re: Questions about Partitioned Tables and Indexes
  In-Reply-To: <1570055847573-0.post@n3.nabble.com>
  References: <CADs92_+KSWg7=N70upjxs7E272MD6RANskbAftcNvZT6146D5g@mail.gmail.com> <1570055847573-0.post@n3.nabble.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