From: Teja Jakkidi <teja.jakkidi05@gmail.com>
To: pgsql-admin <pgsql-admin@lists.postgresql.org>
Subject: Performance issue after creating partitions
Date: Wed, 24 Aug 2022 15:41:08 -0700
Message-ID: <10FAC7AB-09D1-4013-BB3C-79AA3AEDE374@gmail.com> (raw)
Hello Admin team,
We have a Postgres 13 server set up on Google Cloud. Recently we created partitions as below for the tables:
Range on ‘order_date’ column
List on ‘country_code’ column
Quarterly partitions for range.
Order date column is a time stamp column and when we are using this column as a filter in where condition : trunc(order_date) = to_date(’2022-04-01’,’YYYY-MM-DD’), the query scans all the partitions dated back from the year 2000. So, instead of going to the 2022 Q2 partition directly, the query is scanning all the partitions.
But when we remove the trunc() function and just specify order_date =‘2022-04-01 07:02:30’, this works as expected. It goes to the correct partition directly and gets the data.
Can Anyone help me on what’s happening in the first case and why all the partitions are being scanned?
For the first case, when there is a non partition table, it is behaving way better.
Thanks,
J. Teja.
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-admin@postgresql.org
Cc: teja.jakkidi05@gmail.com, pgsql-admin@lists.postgresql.org
Subject: Re: Performance issue after creating partitions
In-Reply-To: <10FAC7AB-09D1-4013-BB3C-79AA3AEDE374@gmail.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