Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- tiktok=> \d videos
- Table "public.videos"
- Column | Type | Collation | Nullable | Default
- ------------+-----------------------------+-----------+----------+---------
- id | character varying(64) | | not null |
- author | character varying(128) | | not null |
- video_info | jsonb | | not null |
- loaded | boolean | | | false
- load_error | boolean | | | false
- fetching | timestamp without time zone | | |
- also | boolean | | |
- Indexes:
- "videos_pkey" PRIMARY KEY, btree (id)
- "video_also_idx" btree (also)
- "video_check_idx" btree (loaded, load_error)
- "video_useful_idx" btree (loaded, load_error)
- "videos_author_idx" btree (author)
- "videos_fetching_idx" btree (fetching)
- "videos_info_idx" gin (video_info jsonb_path_ops)
- "videos_loaded_idx" btree (loaded)
- Foreign-key constraints:
- "videos_author_fkey" FOREIGN KEY (author) REFERENCES authors(user_id)
- tiktok=> explain analyze select id, loaded, also from videos where author = '6805721275644134406' and not loaded order by random() limit 50;
- QUERY PLAN
- -----------------------------------------------------------------------------------------------------------------------------------------------------------
- Limit (cost=411.72..411.85 rows=50 width=29) (actual time=810.168..810.174 rows=22 loops=1)
- -> Sort (cost=411.72..420.77 rows=3621 width=29) (actual time=810.166..810.169 rows=22 loops=1)
- Sort Key: (random())
- Sort Method: quicksort Memory: 26kB
- -> Bitmap Heap Scan on videos (cost=278.37..291.43 rows=3621 width=29) (actual time=810.125..810.144 rows=22 loops=1)
- Recheck Cond: ((author)::text = '6805721275644134406'::text)
- Filter: (NOT loaded)
- Heap Blocks: exact=6
- -> BitmapAnd (cost=278.37..278.37 rows=1 width=0) (actual time=810.103..810.103 rows=0 loops=1)
- -> 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)
- Index Cond: ((author)::text = '6805721275644134406'::text)
- -> 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)
- Index Cond: (loaded = false)
- Planning Time: 0.254 ms
- Execution Time: 810.225 ms
- (15 rows)
- 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;
- QUERY PLAN
- -------------------------------------------------------------------------------------------------------------------------------------------
- Limit (cost=14628.41..14628.54 rows=50 width=156) (actual time=0.103..0.108 rows=22 loops=1)
- CTE author_v
- -> 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)
- Index Cond: ((author)::text = '6805721275644134406'::text)
- -> Sort (cost=137.22..141.75 rows=1812 width=156) (actual time=0.102..0.104 rows=22 loops=1)
- Sort Key: (random())
- Sort Method: quicksort Memory: 26kB
- -> CTE Scan on author_v (cost=0.00..77.03 rows=1812 width=156) (actual time=0.046..0.084 rows=22 loops=1)
- Filter: (NOT loaded)
- Rows Removed by Filter: 1
- Planning Time: 0.200 ms
- Execution Time: 0.141 ms
- (12 rows)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement