Re: Slow query on partitioned table.

From: Justin Pryzby <pryzby(at)telsasoft(dot)com>
To: Glenn Pierce <glennpierce(at)gmail(dot)com>
Cc: pgsql-performance(at)lists(dot)postgresql(dot)org
Subject: Re: Slow query on partitioned table.
Date: 2018-03-27 14:43:15
Message-ID: 20180327144315.GO28454@telsasoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Tue, Mar 27, 2018 at 03:14:30PM +0100, Glenn Pierce wrote:
> Hi I am having terrible trouble with a simple partitioned table.
> Select queries are very slow.
....
> The child tables are all like
> Check constraints:
> "sensor_values_2018q1_timestamp_check" CHECK (ts >= '2018-01-01
> 00:00:00+00'::timestamp with time zone AND ts < '2018-04-01
> 01:00:00+01'::timestamp with time zone)

> EXPLAIN (ANALYZE, BUFFERS) SELECT ts::timestamptz, s1.sensor_id, s1.value
> FROM sensor_values s1
> WHERE s1.sensor_id =
> ANY(ARRAY[596304,597992,610978,597998])
> AND s1.ts >= '2000-01-01
> 00:01:01'::timestamptz AND
> s1.ts < '2018-03-20
> 00:01:01'::timestamptz

> Shows the following output
> https://explain.depesz.com/s/c8HU

It's scanning all partitions, so apparently constraint_exclusion isn't working.

Is it because the CHECK has ts with different timezones +00 and +01 ??

Also, it looks funny to use 00:01:01 as the beginning of the day (although I
think it's true that an HR department would understand that better..).

Justin

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Justin Pryzby 2018-03-27 21:00:32 Re: Slow query on partitioned table.
Previous Message Glenn Pierce 2018-03-27 14:14:30 Slow query on partitioned table.