backend
backend copied to clipboard
missing tags_id index on new stories_tags_map partitions
It looks like the tags_id partition is not getting created on new stories_tags_map partitions. I have started a manual script to create the missing indexes, but I think the underlying partition creation stuff needs to be fixed.
mediacloud=# explain select * from stories_tags_map where tags_id = 123456;
QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------------
Gather (cost=1000.58..36004682.34 rows=139796 width=16)
Workers Planned: 4
-> Parallel Append (cost=0.57..35989702.74 rows=34950 width=16)
-> Parallel Bitmap Heap Scan on stories_tags_map_p_16 (cost=15.03..22.10 rows=5 width=16)
Recheck Cond: (tags_id = 123456)
-> Bitmap Index Scan on stories_tags_map_p_16_stories_id_tags_id_unique (cost=0.00..15.03 rows=9 width=0)
Index Cond: (tags_id = 123456)
-> Parallel Index Scan using stories_tags_map_08_tags_id on stories_tags_map_p_08 (cost=0.57..2721.76 rows=1573 width=16)
Index Cond: (tags_id = 123456)
-> Parallel Index Scan using stories_tags_map_07_tags_id on stories_tags_map_p_07 (cost=0.57..2691.34 rows=1561 width=16)
Index Cond: (tags_id = 123456)
-> Parallel Index Scan using stories_tags_map_09_tags_id on stories_tags_map_p_09 (cost=0.57..2525.62 rows=1468 width=16)
Index Cond: (tags_id = 123456)
-> Parallel Index Scan using stories_tags_map_04_tags_id on stories_tags_map_p_04 (cost=0.57..2125.89 rows=1364 width=16)
Index Cond: (tags_id = 123456)
-> Parallel Index Scan using stories_tags_map_03_tags_id on stories_tags_map_p_03 (cost=0.57..1830.31 rows=1152 width=16)
Index Cond: (tags_id = 123456)
-> Parallel Index Scan using stories_tags_map_05_tags_id on stories_tags_map_p_05 (cost=0.57..1606.31 rows=1311 width=16)
Index Cond: (tags_id = 123456)
-> Parallel Index Scan using stories_tags_map_01_tags_id on stories_tags_map_p_01 (cost=0.57..1474.87 rows=1155 width=16)
Index Cond: (tags_id = 123456)
-> Parallel Index Scan using stories_tags_map_00_tags_id on stories_tags_map_p_00 (cost=0.57..1671.23 rows=1061 width=16)
Index Cond: (tags_id = 123456)
-> Parallel Index Scan using stories_tags_map_02_tags_id on stories_tags_map_p_02 (cost=0.57..1369.82 rows=1042 width=16)
Index Cond: (tags_id = 123456)
-> Parallel Index Scan using stories_tags_map_06_tags_id on stories_tags_map_p_06 (cost=0.57..1106.18 rows=985 width=16)
Index Cond: (tags_id = 123456)
-> Parallel Seq Scan on stories_tags_map_p_11 (cost=0.00..6431129.20 rows=5427 width=16)
Filter: (tags_id = 123456)
-> Parallel Seq Scan on stories_tags_map_p_13 (cost=0.00..6348986.20 rows=5145 width=16)
Filter: (tags_id = 123456)
-> Parallel Seq Scan on stories_tags_map_p_14 (cost=0.00..6284714.00 rows=5182 width=16)
Filter: (tags_id = 123456)
-> Parallel Seq Scan on stories_tags_map_p_10 (cost=0.00..6249562.00 rows=4943 width=16)
Filter: (tags_id = 123456)
-> Parallel Seq Scan on stories_tags_map_p_12 (cost=0.00..5961318.20 rows=4816 width=16)
Filter: (tags_id = 123456)
-> Parallel Seq Scan on stories_tags_map_p_15 (cost=0.00..4694672.96 rows=4048 width=16)
Filter: (tags_id = 123456)
-> Parallel Seq Scan on stories_tags_map_p (cost=0.00..0.00 rows=1 width=16)
Filter: (tags_id = 123456)
(41 rows)
mediacloud=# \d stories_tags_map_p_12
Table "public.stories_tags_map_p_12"
Column | Type | Collation | Nullable | Default
-----------------------+---------+-----------+----------+-------------------------------------------------------------------
stories_tags_map_p_id | bigint | | not null | nextval('stories_tags_map_p_stories_tags_map_p_id_seq'::regclass)
stories_id | integer | | not null |
tags_id | integer | | not null |
Indexes:
"stories_tags_map_p_12_pkey" PRIMARY KEY, btree (stories_tags_map_p_id)
"stories_tags_map_p_12_stories_id_tags_id_unique" UNIQUE CONSTRAINT, btree (stories_id, tags_id)
Check constraints:
"stories_tags_map_p_12_stories_id" CHECK (stories_id >= 1200000000 AND stories_id < 1300000000)
Foreign-key constraints:
"stories_tags_map_p_12_stories_id_fkey" FOREIGN KEY (stories_id) REFERENCES stories(stories_id) MATCH FULL ON DELETE CASCADE
"stories_tags_map_p_12_tags_id_fkey" FOREIGN KEY (tags_id) REFERENCES tags(tags_id) MATCH FULL ON DELETE CASCADE
Inherits: stories_tags_map_p
mediacloud=#