Back

SQL Details

Executed SQL
EXPLAIN SELECT category.status AS category_status, category.created_at AS category_created_at, category.deleted_at AS category_deleted_at, category.id AS category_id, category.title AS category_title, category.slug AS category_slug, anon_1.post_id AS anon_1_post_id FROM (SELECT post.id AS post_id FROM post ORDER BY post.priority DESC LIMIT %(param_1)s) AS anon_1 JOIN categories AS categories_1 ON anon_1.post_id = categories_1.post_id JOIN category ON category.id = categories_1.category_id ORDER BY anon_1.post_id
Original query duration
1.6682 ms
QUERY PLAN
Sort (cost=60.63..60.72 rows=34 width=224)
Sort Key: anon_1.post_id
-> Nested Loop (cost=11.83..59.77 rows=34 width=224)
-> Hash Join (cost=11.68..53.09 rows=34 width=8)
Hash Cond: (categories_1.post_id = anon_1.post_id)
-> Seq Scan on categories categories_1 (cost=0.00..32.60 rows=2260 width=8)
-> Hash (cost=11.64..11.64 rows=3 width=4)
-> Subquery Scan on anon_1 (cost=11.60..11.64 rows=3 width=4)
-> Limit (cost=11.60..11.61 rows=3 width=8)
-> Sort (cost=11.60..11.78 rows=70 width=8)
Sort Key: post.priority DESC
-> Seq Scan on post (cost=0.00..10.70 rows=70 width=8)
-> Index Scan using category_pkey on category (cost=0.15..0.19 rows=1 width=220)
Index Cond: (id = categories_1.category_id)