Advertisement
tarkhil

Untitled

Jul 18th, 2020
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.83 KB | None | 0 0
  1. tiktok=> \d videos
  2. Table "public.videos"
  3. Column | Type | Collation | Nullable | Default
  4. ------------+-----------------------------+-----------+----------+---------
  5. id | character varying(64) | | not null |
  6. author | character varying(128) | | not null |
  7. video_info | jsonb | | not null |
  8. loaded | boolean | | | false
  9. load_error | boolean | | | false
  10. fetching | timestamp without time zone | | |
  11. also | boolean | | |
  12. Indexes:
  13. "videos_pkey" PRIMARY KEY, btree (id)
  14. "video_also_idx" btree (also)
  15. "video_check_idx" btree (loaded, load_error)
  16. "video_useful_idx" btree (loaded, load_error)
  17. "videos_author_idx" btree (author)
  18. "videos_fetching_idx" btree (fetching)
  19. "videos_info_idx" gin (video_info jsonb_path_ops)
  20. "videos_loaded_idx" btree (loaded)
  21. Foreign-key constraints:
  22. "videos_author_fkey" FOREIGN KEY (author) REFERENCES authors(user_id)
  23.  
  24. tiktok=> explain analyze select id, loaded, also from videos where author = '6805721275644134406' and not loaded order by random() limit 50;
  25. QUERY PLAN
  26. -----------------------------------------------------------------------------------------------------------------------------------------------------------
  27. Limit (cost=411.72..411.85 rows=50 width=29) (actual time=810.168..810.174 rows=22 loops=1)
  28. -> Sort (cost=411.72..420.77 rows=3621 width=29) (actual time=810.166..810.169 rows=22 loops=1)
  29. Sort Key: (random())
  30. Sort Method: quicksort Memory: 26kB
  31. -> Bitmap Heap Scan on videos (cost=278.37..291.43 rows=3621 width=29) (actual time=810.125..810.144 rows=22 loops=1)
  32. Recheck Cond: ((author)::text = '6805721275644134406'::text)
  33. Filter: (NOT loaded)
  34. Heap Blocks: exact=6
  35. -> BitmapAnd (cost=278.37..278.37 rows=1 width=0) (actual time=810.103..810.103 rows=0 loops=1)
  36. -> Bitmap Index Scan on videos_author_idx (cost=0.00..131.75 rows=3624 width=0) (actual time=0.047..0.047 rows=23 loops=1)
  37. Index Cond: ((author)::text = '6805721275644134406'::text)
  38. -> Bitmap Index Scan on videos_loaded_idx (cost=0.00..144.56 rows=6399 width=0) (actual time=804.432..804.432 rows=6783464 loops=1)
  39. Index Cond: (loaded = false)
  40. Planning Time: 0.254 ms
  41. Execution Time: 810.225 ms
  42. (15 rows)
  43.  
  44. tiktok=> explain analyze with author_v as ( select id, loaded, also from videos where author = '6805721275644134406' ) select * from author_v where not loaded order by random() limit 50;
  45. QUERY PLAN
  46. -------------------------------------------------------------------------------------------------------------------------------------------
  47. Limit (cost=14628.41..14628.54 rows=50 width=156) (actual time=0.103..0.108 rows=22 loops=1)
  48. CTE author_v
  49. -> Index Scan using videos_author_idx on videos (cost=0.57..14491.19 rows=3625 width=21) (actual time=0.040..0.060 rows=23 loops=1)
  50. Index Cond: ((author)::text = '6805721275644134406'::text)
  51. -> Sort (cost=137.22..141.75 rows=1812 width=156) (actual time=0.102..0.104 rows=22 loops=1)
  52. Sort Key: (random())
  53. Sort Method: quicksort Memory: 26kB
  54. -> CTE Scan on author_v (cost=0.00..77.03 rows=1812 width=156) (actual time=0.046..0.084 rows=22 loops=1)
  55. Filter: (NOT loaded)
  56. Rows Removed by Filter: 1
  57. Planning Time: 0.200 ms
  58. Execution Time: 0.141 ms
  59. (12 rows)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement