Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- daniilak=# \d cache_table;
- Table "public.cache_table"
- Column | Type | Collation | Nullable | Default
- -----------+----------+-----------+----------+-----------------------------------------
- id | integer | | not null | nextval('cache_table_id_seq'::regclass)
- id_house | integer | | |
- index_id | integer | | |
- is_actual | smallint | | |
- date | date | | |
- is_del | integer | | |
- id_site | smallint | | |
- Indexes:
- "cache_table_pkey" PRIMARY KEY, btree (id)
- "cache_date" btree (date)
- "cache_i_tempd" btree (index_id)
- "cache_id" btree (id_house, index_id)
- "cache_id_site" btree (id_site)
- "defin_index_test" btree (index_id DESC NULLS LAST)
- Foreign-key constraints:
- "cache_table_id_house_fkey" FOREIGN KEY (id_house) REFERENCES houses(id)
- _______
- _______
- _______
- daniilak=# \d houses;
- Table "public.houses"
- Column | Type | Collation | Nullable | Default
- ---------------+------------------+-----------+----------+------------------------------------
- id | integer | | not null | nextval('houses_id_seq'::regclass)
- id_addresses | integer | | not null |
- object_type | integer | | not null |
- building_type | integer | | not null |
- level | integer | | not null |
- levels | integer | | not null |
- rooms | integer | | not null |
- area | double precision | | not null |
- kitchen_area | double precision | | not null |
- Indexes:
- "houses_pkey" PRIMARY KEY, btree (id)
- "houses_index" btree (id_addresses)
- "houses_index_bt" btree (building_type)
- "houses_index_level" btree (level)
- "houses_index_levels" btree (levels)
- "houses_index_ot" btree (object_type)
- "houses_index_rooms" btree (rooms)
- Referenced by:
- TABLE "cache_table" CONSTRAINT "cache_table_id_house_fkey" FOREIGN KEY (id_house) REFERENCES houses(id)
- _______
- _______
- _______
- EXPLAIN (ANALYZE, BUFFERS)
- SELECT "t1"."index_id" FROM "cache_table" AS "t1"
- INNER JOIN "houses" AS "t2"
- ON ("t1"."id_house" = "t2"."id")
- WHERE
- ((("t1"."date" > '2020-09-10'))
- AND ("t2"."id_addresses" IN (1144798, 1981271, 4375083, 4375184, 4396416, 12995352, 12998112)))
- ORDER BY "t1"."index_id" DESC
- LIMIT 10
- OFFSET 0;
- _______
- _______
- _______
- Limit (cost=1001.19..92234.31 rows=10 width=4) (actual time=8678.113..34508.759 rows=10 loops=1)
- Buffers: shared hit=168262959
- -> Gather Merge (cost=1001.19..4708630.03 rows=516 width=4) (actual time=8678.111..34508.754 rows=10 loops=1)
- Workers Planned: 4
- Workers Launched: 4
- Buffers: shared hit=168262959
- -> Nested Loop (cost=1.13..4707568.51 rows=129 width=4) (actual time=4086.167..24355.133 rows=4 loops=5)
- Buffers: shared hit=168262959
- -> Parallel Index Scan Backward using cache_i_tempd on cache_table t1 (cost=0.57..1464208.54 rows=5076380 width=8) (actual time=0.044..11495.012 rows=3990460 loops=5)
- Filter: (date > '2020-09-10'::date)
- Rows Removed by Filter: 10251594
- Buffers: shared hit=68393948
- -> Index Scan using houses_pkey on houses t2 (cost=0.56..0.64 rows=1 width=4) (actual time=0.003..0.003 rows=0 loops=19952302)
- Index Cond: (id = t1.id_house)
- Filter: (id_addresses = ANY ('{1144798,1981271,4375083,4375184,4396416,12995352,12998112}'::integer[]))
- Rows Removed by Filter: 1
- Buffers: shared hit=99869011
- Planning Time: 0.238 ms
- Execution Time: 34508.786 ms
- (19 rows)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement