Re: why partition pruning doesn't work?
| От | Dmitry Dolgov |
|---|---|
| Тема | Re: why partition pruning doesn't work? |
| Дата | |
| Msg-id | CA+q6zcV5=8JoDTBNO0EUDG7++Rj_GE89MQ1sYMHLHZs5pm3V8g@mail.gmail.com обсуждение исходный текст |
| Ответ на | why partition pruning doesn't work? (Pavel Stehule <pavel.stehule@gmail.com>) |
| Ответы |
Re: why partition pruning doesn't work?
|
| Список | pgsql-hackers |
> On 1 June 2018 at 07:19, Pavel Stehule <pavel.stehule@gmail.com> wrote:
>
> Partition pruning is working now.
>
> Is it expected? Tested on fresh master.
That's interesting. So there are two cases:
* vlozeno > (select current_date) (pruning works)
* vlozeno > current_date (pruning doesn't work)
In pull_partkey_params when we need to extract Params matching partition key in
the first case everything is fine, we've got an expr of type Param. In the
second case we've got a SQLValueFunction, which is ignored in the code - so
eventually we think that there is nothing matching a partition key and we don't
need to apply pruning.
With the attached hacky patch it would be taken into account (although I assume
in reality SQLValueFunction should be treated somehow differently) and pruning
is happening:
=# explain analyze select * from data where vlozeno > current_date;
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------
Gather (cost=1000.00..17223.38 rows=19512 width=9) (actual
time=0.456..32.952 rows=19340 loop s=1)
Workers Planned: 2
Workers Launched: 2
-> Parallel Append (cost=0.00..14272.18 rows=8130 width=9)
(actual time=0.042..26.616 rows =6447 loops=3)
-> Parallel Seq Scan on data_2016 (cost=0.00..5771.19
rows=24 width=9) (never executed)
Filter: (vlozeno > CURRENT_DATE)
-> Parallel Seq Scan on data_2017 (cost=0.00..5747.65
rows=23 width=9) (never executed)
Filter: (vlozeno > CURRENT_DATE)
-> Parallel Seq Scan on data_other (cost=0.00..2712.69
rows=11431 width=9) (actual time=0.032..26.031 rows=6447 loops=3)
Filter: (vlozeno > CURRENT_DATE)
Rows Removed by Filter: 57084
Planning Time: 1.256 ms
Execution Time: 35.327 ms
(13 rows)
Time: 40.291 ms
Вложения
В списке pgsql-hackers по дате отправления: