Advertisement
daniilak

Untitled

Jul 7th, 2021
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. daniilak=# \d cache_table;
  2.                               Table "public.cache_table"
  3.   Column   |   Type   | Collation | Nullable |                 Default
  4. -----------+----------+-----------+----------+-----------------------------------------
  5.  id        | integer  |           | not null | nextval('cache_table_id_seq'::regclass)
  6.  id_house  | integer  |           |          |
  7.  index_id  | integer  |           |          |
  8.  is_actual | smallint |           |          |
  9.  date      | date     |           |          |
  10.  is_del    | integer  |           |          |
  11.  id_site   | smallint |           |          |
  12. Indexes:
  13.     "cache_table_pkey" PRIMARY KEY, btree (id)
  14.     "cache_date" btree (date)
  15.     "cache_i_tempd" btree (index_id)
  16.     "cache_id" btree (id_house, index_id)
  17.     "cache_id_site" btree (id_site)
  18.     "defin_index_test" btree (index_id DESC NULLS LAST)
  19. Foreign-key constraints:
  20.     "cache_table_id_house_fkey" FOREIGN KEY (id_house) REFERENCES houses(id)
  21. _______
  22. _______
  23. _______
  24. daniilak=# \d houses;
  25.                                     Table "public.houses"
  26.     Column     |       Type       | Collation | Nullable |              Default
  27. ---------------+------------------+-----------+----------+------------------------------------
  28.  id            | integer          |           | not null | nextval('houses_id_seq'::regclass)
  29.  id_addresses  | integer          |           | not null |
  30.  object_type   | integer          |           | not null |
  31.  building_type | integer          |           | not null |
  32.  level         | integer          |           | not null |
  33.  levels        | integer          |           | not null |
  34.  rooms         | integer          |           | not null |
  35.  area          | double precision |           | not null |
  36.  kitchen_area  | double precision |           | not null |
  37. Indexes:
  38.     "houses_pkey" PRIMARY KEY, btree (id)
  39.     "houses_index" btree (id_addresses)
  40.     "houses_index_bt" btree (building_type)
  41.     "houses_index_level" btree (level)
  42.     "houses_index_levels" btree (levels)
  43.     "houses_index_ot" btree (object_type)
  44.     "houses_index_rooms" btree (rooms)
  45. Referenced by:
  46.     TABLE "cache_table" CONSTRAINT "cache_table_id_house_fkey" FOREIGN KEY (id_house) REFERENCES houses(id)
  47. _______
  48. _______
  49. _______
  50.  
  51. EXPLAIN (ANALYZE, BUFFERS)  
  52. SELECT "t1"."index_id" FROM "cache_table" AS "t1"
  53. INNER JOIN "houses" AS "t2"
  54.     ON ("t1"."id_house" = "t2"."id")
  55. WHERE
  56.     ((("t1"."date" > '2020-09-10'))
  57. AND ("t2"."id_addresses" IN (1144798, 1981271, 4375083, 4375184, 4396416, 12995352, 12998112)))
  58. ORDER BY "t1"."index_id" DESC
  59. LIMIT 10
  60. OFFSET 0;
  61. _______
  62. _______
  63. _______
  64.  
  65.  
  66.  Limit  (cost=1001.19..92234.31 rows=10 width=4) (actual time=8678.113..34508.759 rows=10 loops=1)
  67.    Buffers: shared hit=168262959
  68.    ->  Gather Merge  (cost=1001.19..4708630.03 rows=516 width=4) (actual time=8678.111..34508.754 rows=10 loops=1)
  69.          Workers Planned: 4
  70.          Workers Launched: 4
  71.          Buffers: shared hit=168262959
  72.          ->  Nested Loop  (cost=1.13..4707568.51 rows=129 width=4) (actual time=4086.167..24355.133 rows=4 loops=5)
  73.                Buffers: shared hit=168262959
  74.                ->  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)
  75.                      Filter: (date > '2020-09-10'::date)
  76.                      Rows Removed by Filter: 10251594
  77.                      Buffers: shared hit=68393948
  78.                ->  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)
  79.                      Index Cond: (id = t1.id_house)
  80.                      Filter: (id_addresses = ANY ('{1144798,1981271,4375083,4375184,4396416,12995352,12998112}'::integer[]))
  81.                      Rows Removed by Filter: 1
  82.                      Buffers: shared hit=99869011
  83.  Planning Time: 0.238 ms
  84.  Execution Time: 34508.786 ms
  85. (19 rows)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement