Partitioned tables in queries

Поиск
Список
Период
Сортировка
От Kevin Keith
Тема Partitioned tables in queries
Дата
Msg-id 44C12852.1040909@borderware.com
обсуждение исходный текст
Ответы Re: Partitioned tables in queries
Re: Partitioned tables in queries
Список pgsql-performance
I have a case where I am partitioning tables based on a date range in
version 8.1.4. For example:

table_with_millions_of_records
interaction_id  char(16) primary key
start_date   timestamp (without timezone) - indexed
.. other columns

child_1   start_date >= 2006-07-21 00:00:00
child_2   start_date >= 2006-07-20 00:00:00 and start_date < 2006-07-21
00:00:00
...
child_5   start_date >= 2006-07-17 00:00:00 and start_date < 2006-07-18
00:00:00

with rules on the parent and child tables that redirect the data to the
appropriate child table based on the start_date.

Because this table is going to grow very large (very quickly), and will
need to be purged daily, I created partitions, or child tables to hold
data for each day. I have done the same thing in Oracle in the past, and
the PostgreSQL solution works great. The archival process is very simple
- drop the expired child table. I am having one problem.

If I run a query on the full table (there are 5 child tables with data
for the last 5 days), and my where clause contains data for the current
day only:
where start_date > date_trunc('day', now())
all 5 child tables are scanned when I look at the output from explain
analyze.

My question is - can I force the planner to only scan the relevant child
table - when the key related to the partitioned data it part of the
where clause?

Thanks,

Kevin


...

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

Предыдущее
От: "Kevin McArthur"
Дата:
Сообщение: Bad Planner Statistics for Uneven distribution.
Следующее
От: Steve Atkins
Дата:
Сообщение: Re: Partitioned tables in queries