Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am jchen123 on github.
  • I am jchen123 (https://keybase.io/jchen123) on keybase.
  • I have a public key whose fingerprint is 8A48 4485 4996 06DB 0E67 68AB 9B21 8D3D EF82 2C9F

To claim this, I am signing this object:

@jchen123
jchen123 / gist:5696615
Created June 3, 2013 07:36
bad analyze
"Nested Loop Left Join (cost=0.00..68319.25 rows=523 width=29) (actual time=30.744..283.629 rows=3648 loops=1)"
" -> Nested Loop (cost=0.00..64218.45 rows=523 width=12) (actual time=30.736..274.287 rows=3648 loops=1)"
" -> Index Only Scan using albums_pkey on albums (cost=0.00..8.27 rows=1 width=4) (actual time=0.013..0.016 rows=1 loops=1)"
" Index Cond: (id = 1060)"
" Heap Fetches: 1"
" -> Nested Loop (cost=0.00..64204.95 rows=523 width=12) (actual time=30.722..273.716 rows=3648 loops=1)"
" -> Seq Scan on album_photos (cost=0.00..59111.40 rows=611 width=8) (actual time=30.698..259.694 rows=3924 loops=1)"
" Filter: (album_id = 1060)"
" Rows Removed by Filter: 2254428"
" -> Index Scan using photos_pkey on photos (cost=0.00..8.33 rows=1 width=8) (actual time=0.003..0.003 rows=1 loops=3924)"
@jchen123
jchen123 / gist:5696312
Last active December 18, 2015 00:28
explain analyze example
EXPLAIN ANALYZE SELECT
photos.id, album_photos.album_id, connected_users.email_address
FROM photos JOIN album_photos ON album_photos.photo_id = photos.id
JOIN albums ON album_photos.album_id = albums.id
LEFT OUTER JOIN connected_users ON photos.connected_user_id = connected_users.id
WHERE album_photos.album_id = 1060
AND photos.dead is not true
@jchen123
jchen123 / gist:5696309
Last active December 18, 2015 00:28
explain analyze result
"Nested Loop Left Join (cost=13.23..11398.05 rows=523 width=29) (actual time=2.111..32.453 rows=3648 loops=1)"
" -> Nested Loop (cost=13.23..7297.25 rows=523 width=12) (actual time=2.101..21.872 rows=3648 loops=1)"
" -> Index Only Scan using albums_pkey on albums (cost=0.00..8.27 rows=1 width=4) (actual time=0.048..0.049 rows=1 loops=1)"
" Index Cond: (id = 1060)"
" Heap Fetches: 1"
" -> Nested Loop (cost=13.23..7283.75 rows=523 width=12) (actual time=2.045..21.312 rows=3648 loops=1)"
" -> Bitmap Heap Scan on album_photos (cost=13.23..2190.20 rows=611 width=8) (actual time=2.019..4.724 rows=3924 loops=1)"
" Recheck Cond: (album_id = 1060)"
" -> Bitmap Index Scan on index_album_photos_on_album_id_and_photo_id (cost=0.00..13.08 rows=611 width=0) (actual time=1.923..1.923 rows=3924 loops=1)"
" Index Cond: (album_id = 1060)"