pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Yuzuko Hosoya <hosoya.yuzuko@lab.ntt.co.jp>
To: pgsql-hackers@lists.postgresql.org
Subject: Runtime pruning problem
Date: Tue, 16 Apr 2019 20:54:36 +0900
Message-ID: <001001d4f44b$2a2cca50$7e865ef0$@lab.ntt.co.jp> (raw)

Hi all,

I found a runtime pruning test case which may be a problem as follows:

----
create table t1 (id int, dt date) partition by range(dt);
create table t1_1 partition of t1 for values from ('2019-01-01') to ('2019-04-01');
create table t1_2 partition of t1 for values from ('2019-04-01') to ('2019-07-01');
create table t1_3 partition of t1 for values from ('2019-07-01') to ('2019-10-01');
create table t1_4 partition of t1 for values from ('2019-10-01') to ('2020-01-01');

In this example, current_date is 2019-04-16.

postgres=# explain select * from t1 where dt = current_date + 400;
                         QUERY PLAN                         
------------------------------------------------------------
 Append  (cost=0.00..198.42 rows=44 width=8)
   Subplans Removed: 3
   ->  Seq Scan on t1_1  (cost=0.00..49.55 rows=11 width=8)
         Filter: (dt = (CURRENT_DATE + 400))
(4 rows)

postgres=# explain analyze select * from t1 where dt = current_date + 400;
                                      QUERY PLAN                                       
---------------------------------------------------------------------------------------
 Append  (cost=0.00..198.42 rows=44 width=8) (actual time=0.000..0.001 rows=0 loops=1)
   Subplans Removed: 3
   ->  Seq Scan on t1_1  (cost=0.00..49.55 rows=11 width=8) (never executed)
         Filter: (dt = (CURRENT_DATE + 400))
 Planning Time: 0.400 ms
 Execution Time: 0.070 ms
(6 rows)
----

I realized t1_1 was not scanned actually since "never executed" 
was displayed in the plan using EXPLAIN ANALYZE.  But I think 
"One-Time Filter: false" and "Subplans Removed: ALL" or something
like that should be displayed instead.

What do you think?


Best regards,
Yuzuko Hosoya
NTT Open Source Software Center







view thread (38+ messages)  latest in thread

Message-ID: <001001d4f44b$2a2cca50$7e865ef0$@lab.ntt.co.jp>
Permalink:  ../001001d4f44b$2a2cca50$7e865ef0$@lab.ntt.co.jp/
Also on:    postgresql.org/message-id/001001d4f44b$2a2cca50$7e865ef0$@lab.ntt.co.jp

 · 

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-hackers@postgresql.org
  Cc: hosoya.yuzuko@lab.ntt.co.jp, pgsql-hackers@lists.postgresql.org
  Subject: Re: Runtime pruning problem
  In-Reply-To: <001001d4f44b$2a2cca50$7e865ef0$@lab.ntt.co.jp>

* 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