From: | David Rowley <dgrowleyml(at)gmail(dot)com> |
---|---|
To: | Cedric Leong <cedricleong(at)gmail(dot)com> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Pgsql Performance <pgsql-performance(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Date vs Timestamp without timezone Partition Key |
Date: | 2020-06-06 03:13:40 |
Message-ID: | CAApHDvqA8zY4vGXYhP6DUZU3RkzqdY1bWgcMOXiM3G=+P4Bv3w@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
On Sat, 6 Jun 2020 at 14:49, Cedric Leong <cedricleong(at)gmail(dot)com> wrote:
> It's less of a complaint rather than just a warning not to do what I did.
My point was really that nobody really knew what you did or what you
did it on. So it didn't seem like a worthwhile warning as it
completely lacked detail.
> These tests are running the exact same query on two different tables with the exception that they use their respective partition keys.
Are you sure? It looks like the old one does WHERE date =
((now())::date - '7 days'::interval) and the new version does
(date(created_at) = ((now())::date - '7 days'::interval). I guess you
renamed date to "created_at" and changed the query to use date(). If
that expression is not indexed then I imagine that would be a good
reason for the planner to have moved away from using the index on that
column. Also having date(created_at) will also not allow run-time
pruning to work since your partition key is "created_at".
You might be able to change the query to query a range of value on the
new timestamp column. This will allow you to get rid of the date()
function. For example:
where created_at >= date_trunc('day', now() - '7 days'::interval) and
created_at < date_trunc('day', now() - '6 days'::interval)
David
From | Date | Subject | |
---|---|---|---|
Next Message | Cedric Leong | 2020-06-06 03:56:18 | Re: Date vs Timestamp without timezone Partition Key |
Previous Message | Cedric Leong | 2020-06-06 02:49:46 | Re: Date vs Timestamp without timezone Partition Key |