From: Justin Pryzby <pryzby@telsasoft.com>
To: Mariel Cherkassky <mariel.cherkassky@gmail.com>
Cc: Andreas Kretschmer <andreas@a-kretschmer.de>
Cc: pgsql-performance@lists.postgresql.org
Subject: Re: postgresql 10.1 wrong plan in when using partitions bug
Date: Mon, 5 Feb 2018 13:19:22 -0600
Message-ID: <20180205191922.GN32634@telsasoft.com> (raw)
In-Reply-To: <CA+t6e1m-m94iJTSD3X+uKJ_=c6dMCjL5ntWMf_d-T6JM8z=S2A@mail.gmail.com>
References: <CA+t6e1m54jrEj7spf9ArH5BJiO-Qznn=_YCRGWWMtohvXg7mEg@mail.gmail.com>
<f042e9cb-be4b-4215-4165-8a14313cbdf7@2ndquadrant.com>
<CA+t6e1mt-fkvZZX5Wx8B1oPrw=DQOZGr3s=xU_ZhEhKEJtJ-Og@mail.gmail.com>
<fe3a1929-c843-e10a-8580-302c60db4c13@a-kretschmer.de>
<CA+t6e1niwYE_F-fpnwFfZNy-Qk9-2RJT5P4F4UTJatLG2iseVg@mail.gmail.com>
<20180204152532.GT26916@telsasoft.com>
<CA+t6e1m-m94iJTSD3X+uKJ_=c6dMCjL5ntWMf_d-T6JM8z=S2A@mail.gmail.com>
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@a-kretschmer.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.
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-performance@postgresql.org
Cc: pryzby@telsasoft.com, mariel.cherkassky@gmail.com, andreas@a-kretschmer.de, pgsql-performance@lists.postgresql.org
Subject: Re: postgresql 10.1 wrong plan in when using partitions bug
In-Reply-To: <20180205191922.GN32634@telsasoft.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