Hi,
I'm trying to understand the execution plan that is chosen for my query when I run a select on a partition table . I have on my main partition table rules that redirect the insert to the right son table.
My scheme :
Postgresql 9.6.8
mydb=# \d comments_daily
Table "public.fw_log_daily"
Column | Type | Modifiers
---------------+-----------------------+-----------
log_server_id | bigint | not null
comment_id | bigint | not null
date | date | not null
Rules:
comments_daily_1 AS
ON INSERT TO fw_log_daily
WHERE new.log_server_id = 1::bigint DO INSTEAD INSERT INTO comments_daily_1 (log_server_id,comment_id, date)
VALUES (new.log_server_id, new.comment_id, new.date)
comments_daily_2 AS
ON INSERT TO fw_log_daily
WHERE new.log_server_id = 1::bigint DO INSTEAD INSERT INTO comments_daily_2 (log_server_id, comment_id, date)
VALUES (new.log_server_id, new.comment_id, new.date)
and so on...
The son table structure :
mydb=# \d comments_daily_247
Table "public.comments_daily_247"
Column | Type | Modifiers
---------------+-----------------------+-----------
log_server_id | bigint | not null
comment_id | bigint | not null
date | date | not null
Indexes:
"comments_daily_247_date_device_id_idx" btree (date, device_id)
Check constraints:
"comments_daily_247_log_server_id_check" CHECK (log_server_id = 247::bigint)
Inherits: comments_daily
----------------------------------------------------------------------------------------------------------------------------------
-> Index Scan using comments_daily_247_date_comment_id_idx on comments_daily_247 (cost=0.15..8.19 rows=1 width=186)