Re: Partitioning versus autovacuum

From: yuzuko <yuzukohosoya(at)gmail(dot)com>
To: Greg Stark <stark(at)mit(dot)edu>
Cc: Amit Langote <amitlangote09(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Partitioning versus autovacuum
Date: 2019-12-02 09:25:37
Message-ID: CAKkQ509BBXfBu0NoEUhvckNJDKeQT+dVK8VZ=JXEfoTwnGs2Ow@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello Greg,

> At the risk of forking this thread... I think there's actually a
> planner estimation bug here too.
>
I think that is not a bug. The estimation error occurred there were no
parent's statistics. We should run analyze on *partitioned table*.

Here is your test case:
create table p (i integer, j integer) partition by list (i);
create table p0 partition of p for values in (0);
create table p1 partition of p for values in (1);
insert into p select 0,generate_series(1,1000);
insert into p select 1,generate_series(1,1000);
analyze p;

explain analyze select * from q join p using (i) where j between 1 and 500;
QUERY PLAN
-------------------------------------------------------------------------------------------------------------
Hash Join (cost=1.02..54.77 rows=500 width=8) (actual
time=0.180..2.960 rows=500 loops=1)
Hash Cond: (p0.i = q.i)
-> Append (cost=0.00..45.00 rows=1000 width=8) (actual
time=0.033..1.887 rows=1000 loops=1)
-> Seq Scan on p0 (cost=0.00..20.00 rows=500 width=8)
(actual time=0.025..0.524 rows=500 loops=1)
Filter: ((j >= 1) AND (j <= 500))
Rows Removed by Filter: 500
-> Seq Scan on p1 (cost=0.00..20.00 rows=500 width=8)
(actual time=0.014..0.499 rows=500 loops=1)
Filter: ((j >= 1) AND (j <= 500))
Rows Removed by Filter: 500
-> Hash (cost=1.01..1.01 rows=1 width=4) (actual
time=0.103..0.104 rows=1 loops=1)
Buckets: 1024 Batches: 1 Memory Usage: 9kB
-> Seq Scan on q (cost=0.00..1.01 rows=1 width=4) (actual
time=0.072..0.074 rows=1 loops=1)
Planning Time: 0.835 ms
Execution Time: 3.310 ms
(14 rows)

--
Best regards,
Yuzuko Hosoya
NTT Open Source Software Center

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Alexey Kondratov 2019-12-02 09:41:03 Re: Allow CLUSTER, VACUUM FULL and REINDEX to change tablespace on the fly
Previous Message Laurenz Albe 2019-12-02 09:19:01 Re: Autovacuum on partitioned table