Advertisement
Guest User

Untitled

a guest
Jul 16th, 2018
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.68 KB | None | 0 0
  1. chinese=# EXPLAIN ANALYZE SELECT COUNT(sentence_word.sentence_id) FROM content JOIN sentence ON sentence.content_id=content.id JOIN sentence_word ON sentence_word.sentence_id=sentence.id WHERE content.source_type=2;
  2. QUERY PLAN
  3. ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  4. Finalize Aggregate (cost=5318457.26..5318457.27 rows=1 width=8) (actual time=40038.643..40038.643 rows=1 loops=1)
  5. -> Gather (cost=5318457.05..5318457.26 rows=2 width=8) (actual time=40038.615..40038.638 rows=3 loops=1)
  6. Workers Planned: 2
  7. Workers Launched: 2
  8. -> Partial Aggregate (cost=5317457.05..5317457.06 rows=1 width=8) (actual time=40035.364..40035.364 rows=1 loops=3)
  9. -> Hash Join (cost=1061549.16..5310334.57 rows=2848991 width=4) (actual time=36729.241..40035.179 rows=1880 loops=3)
  10. Hash Cond: (sentence_word.sentence_id = sentence.id)
  11. -> Parallel Seq Scan on sentence_word (cost=0.00..3628067.00 rows=157927600 width=4) (actual time=0.184..19460.798 rows=126342084 loops=3)
  12. -> Hash (cost=1055734.37..1055734.37 rows=465183 width=4) (actual time=8257.710..8257.710 rows=1226 loops=3)
  13. Buckets: 524288 Batches: 1 Memory Usage: 4140kB
  14. -> Hash Join (cost=1869.26..1055734.37 rows=465183 width=4) (actual time=1970.901..8257.408 rows=1226 loops=3)
  15. Hash Cond: (sentence.content_id = content.id)
  16. -> Seq Scan on sentence (cost=0.00..728315.08 rows=25786408 width=8) (actual time=0.105..4871.221 rows=25771768 loops=3)
  17. -> Hash (cost=1853.89..1853.89 rows=1229 width=4) (actual time=20.081..20.081 rows=1246 loops=3)
  18. Buckets: 2048 Batches: 1 Memory Usage: 60kB
  19. -> Bitmap Heap Scan on content (cost=25.82..1853.89 rows=1229 width=4) (actual time=0.396..19.817 rows=1246 loops=3)
  20. Recheck Cond: (source_type = 2)
  21. Heap Blocks: exact=170
  22. -> Bitmap Index Scan on content_source_idx (cost=0.00..25.51 rows=1229 width=0) (actual time=0.314..0.314 rows=1246 loops=3)
  23. Index Cond: (source_type = 2)
  24. Planning time: 9.665 ms
  25. Execution time: 40041.929 ms
  26. (22 rows)
  27.  
  28.  
  29. chinese=# set enable_seqscan=off;
  30. SET
  31. chinese=# EXPLAIN ANALYZE SELECT COUNT(sentence_word.sentence_id) FROM content JOIN sentence ON sentence.content_id=content.id JOIN sentence_word ON sentence_word.sentence_id=sentence.id WHERE content.source_type=2;
  32. QUERY PLAN
  33. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  34. Finalize Aggregate (cost=32594154.72..32594154.73 rows=1 width=8) (actual time=80.898..80.898 rows=1 loops=1)
  35. -> Gather (cost=32594154.60..32594154.71 rows=1 width=8) (actual time=80.883..80.894 rows=2 loops=1)
  36. Workers Planned: 1
  37. Workers Launched: 1
  38. -> Partial Aggregate (cost=32593154.60..32593154.61 rows=1 width=8) (actual time=79.146..79.147 rows=1 loops=2)
  39. -> Nested Loop (cost=58.00..32583099.34 rows=4022105 width=4) (actual time=63.608..78.882 rows=2820 loops=2)
  40. -> Nested Loop (cost=57.42..6895590.47 rows=273637 width=4) (actual time=63.162..75.075 rows=613 loops=2)
  41. -> Parallel Index Scan using content_pkey on content (cost=0.29..215101.03 rows=723 width=4) (actual time=62.474..67.980 rows=623 loops=2)
  42. Filter: (source_type = 2)
  43. Rows Removed by Filter: 33440
  44. -> Bitmap Heap Scan on sentence (cost=57.13..9209.89 rows=3007 width=8) (actual time=0.010..0.010 rows=1 loops=1246)
  45. Recheck Cond: (content_id = content.id)
  46. Heap Blocks: exact=663
  47. -> Bitmap Index Scan on contentidx (cost=0.00..56.38 rows=3007 width=0) (actual time=0.003..0.003 rows=1 loops=1246)
  48. Index Cond: (content_id = content.id)
  49. -> Index Only Scan using sentenceidx on sentence_word (cost=0.57..93.55 rows=32 width=4) (actual time=0.004..0.005 rows=5 loops=1226)
  50. Index Cond: (sentence_id = sentence.id)
  51. Heap Fetches: 2991
  52. Planning time: 1.118 ms
  53. Execution time: 84.193 ms
  54. (20 rows)
  55.  
  56.  
  57. chinese=# \d sentence_word
  58. Table "public.sentence_word"
  59. Column | Type | Collation | Nullable | Default
  60. -------------+---------+-----------+----------+---------
  61. sentence_id | integer | | not null |
  62. word_id | integer | | not null |
  63. position | integer | | not null |
  64. Indexes:
  65. "sentenceidx" btree (sentence_id)
  66. "sentencewordidx" btree (word_id)
  67.  
  68.  
  69.  
  70. chinese=# \d sentence
  71. Table "public.sentence"
  72. Column | Type | Collation | Nullable | Default
  73. ---------------------+-----------------------------+-----------+----------+--------------------------------------
  74. id | integer | | not null | nextval('sentence_id_seq'::regclass)
  75. sentence_s | text | | |
  76. sentence_t | text | | |
  77. original_script | text | | not null |
  78. segmentation_method | integer | | |
  79. content_id | integer | | |
  80. word_ids_json | jsonb | | |
  81. created | timestamp without time zone | | | CURRENT_TIMESTAMP
  82. updated | timestamp without time zone | | | CURRENT_TIMESTAMP
  83. Indexes:
  84. "sentence_pkey" PRIMARY KEY, btree (id)
  85. "contentidx" btree (content_id)
  86. Foreign-key constraints:
  87. "sentence_content_id_fkey" FOREIGN KEY (content_id) REFERENCES content(id) ON DELETE CASCADE
  88.  
  89.  
  90. chinese=# \d content
  91. Table "public.content"
  92. Column | Type | Collation | Nullable | Default
  93. -----------------------+-----------------------------+-----------+----------+-------------------------------------
  94. id | integer | | not null | nextval('content_id_seq'::regclass)
  95. content_s | text | | |
  96. content_t | text | | |
  97. original_script | text | | not null |
  98. content_translation | text | | |
  99. title_s | text | | |
  100. title_t | text | | |
  101. source_type | integer | | |
  102. source_url | text | | |
  103. source_uniqid | text | | |
  104. user_id | integer | | |
  105. line_splitting_method | integer | | |
  106. sentences_updated | timestamp without time zone | | |
  107. created | timestamp without time zone | | | CURRENT_TIMESTAMP
  108. updated | timestamp without time zone | | | CURRENT_TIMESTAMP
  109. has_children | boolean | | not null | false
  110. source_title | text | | |
  111. content_type | text | | |
  112. genre | text | | |
  113. date_written | timestamp without time zone | | |
  114. parent_content_id | integer | | |
  115. imdbid | integer | | |
  116. omdbapi_response | jsonb | | |
  117. imdbapi_response | jsonb | | |
  118. Indexes:
  119. "content_pkey" PRIMARY KEY, btree (id)
  120. "content_source_idx" btree (source_type)
  121. Foreign-key constraints:
  122. "content_parent_content_id_fkey" FOREIGN KEY (parent_content_id) REFERENCES content(id) ON DELETE CASCADE
  123. Referenced by:
  124. TABLE "content" CONSTRAINT "content_parent_content_id_fkey" FOREIGN KEY (parent_content_id) REFERENCES content(id) ON DELETE CASCADE
  125. TABLE "open_subtitle" CONSTRAINT "open_subtitle_content_id_fkey" FOREIGN KEY (content_id) REFERENCES content(id) ON DELETE CASCADE
  126. TABLE "sentence" CONSTRAINT "sentence_content_id_fkey" FOREIGN KEY (content_id) REFERENCES content(id) ON DELETE CASCADE
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement