Re: postgresql 10.1 wrong plan in when using partitions bug

From: Justin Pryzby <pryzby(at)telsasoft(dot)com>
To: Mariel Cherkassky <mariel(dot)cherkassky(at)gmail(dot)com>
Cc: Andreas Kretschmer <andreas(at)a-kretschmer(dot)de>, pgsql-performance(at)lists(dot)postgresql(dot)org
Subject: Re: postgresql 10.1 wrong plan in when using partitions bug
Date: 2018-02-05 19:19:22
Message-ID: 20180205191922.GN32634@telsasoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Sun, Feb 04, 2018 at 05:28:52PM +0200, Mariel Cherkassky wrote:
> I read those two links and I dont think that they are relevant because : 1
> 1)I didnt do any join.
> 2)I used a where clause in my select

https://www.postgresql.org/docs/current/static/ddl-partitioning.html
|The following caveats apply to constraint exclusion:
| Constraint exclusion only works when the query's WHERE clause contains
|constants (or externally supplied parameters). For example, a comparison
|against a non-immutable function such as CURRENT_TIMESTAMP cannot be optimized,
|since the planner cannot know which partition the function value might fall
|into at run time.
[..]

The issue is with the comparison between function call to to_date() compared
with constant - that doesn't allow constraint exclusion as currently
implemented.

Justin

2018-02-04 16:54 GMT+02:00 Andreas Kretschmer <andreas(at)a-kretschmer(dot)de>:
> > Am 04.02.2018 um 13:19 schrieb Mariel Cherkassky:
> > > >
> > > >> I checked the plan of the next query :
> > > >> explain select count(*) from log_full where end_date between
> > > >> to_date('2017/12/03','YY/MM/DD') and to_date('2017/12/03','YY/MM/
> > DD');
> > > >>
> > > >>
> > > > can you rewrite the query to
> > > >
> > > > ... where end_date between '2017/12/03' and '2017/12/03'
> > > >
> > > > maybe the planner should be smart enough to do that for you, but obvously
> > > > he can't. So it's a workaround, but it seems to solve the problem.

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Claudio Freire 2018-02-05 20:14:53 Re: effective_io_concurrency on EBS/gp2
Previous Message Tomas Vondra 2018-02-05 19:15:02 Re: SV: bad plan using nested loops