Constraint exclusion not working - need different constraints?

Поиск
Список
Период
Сортировка
От Doug Gorley
Тема Constraint exclusion not working - need different constraints?
Дата
Msg-id 20150527142214.akz9k6wav40cwcoo@webmail.internethosting.com
обсуждение исходный текст
Ответы Re: Constraint exclusion not working - need different constraints?
Список pgsql-general
Good day,

I'm attempting to implement table partitioning with constraint exclusions,
but I'm not seeing the planner limit the plan to an appropriate set of
child tables.  I'm wondering if the functions in my constraints are making
the exclusion impossible.

My constraints look like this:

    ALTER TABLE response_data.queries_response_2015w23
      ADD CONSTRAINT queries_response_2015w23_timestamp_check
          CHECK (
             date_part('year'::text, "timestamp"::timestamp without time zone) = 2015::double precision AND
             date_part('week'::text, "timestamp"::timestamp without time zone) = 23::double precision
          );

And my query looks like this:

    explain select * from public.queries_response where age("timestamp"::timestamp) < '24 hours';
   
http://www.postgresql.org/docs/9.4/static/ddl-partitioning.html gives this caveat:

    "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."
   
Will I likely need to replace the date_part functions with actual dates to
make this work?

Thanks,
--
Doug Gorley | doug@gorley.ca


В списке pgsql-general по дате отправления:

Предыдущее
От: PT
Дата:
Сообщение: Re: Fwd: Raster performance
Следующее
От: Steve Kehlet
Дата:
Сообщение: 9.4.1 -> 9.4.2 problem: could not access status of transaction 1