Skip to content

Instantly share code, notes, and snippets.

@bharath-kotha
Created August 7, 2022 06:18
Show Gist options
  • Save bharath-kotha/a6036a8db12db831d4739ff0410c34bf to your computer and use it in GitHub Desktop.
Save bharath-kotha/a6036a8db12db831d4739ff0410c34bf to your computer and use it in GitHub Desktop.
How SELECT statement can cause disk write IO - Query Plan 1
QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------------------
Limit (cost=0.87..51.28 rows=100 width=206) (actual time=0.023..24.739 rows=100 loops=1)
Buffers: shared hit=255 read=149
-> Nested Loop (cost=0.87..10080882.37 rows=20000000 width=206) (actual time=0.023..24.714 rows=100 loops=1)
Buffers: shared hit=255 read=149
-> Index Scan using book_pkey on book (cost=0.44..666418.44 rows=20000000 width=30) (actual time=0.012..0.069 rows=100 loops=1)
Buffers: shared hit=4
-> Index Scan using author_pkey on author (cost=0.43..0.47 rows=1 width=168) (actual time=0.245..0.245 rows=1 loops=100)
Index Cond: (id = book.author_id)
Buffers: shared hit=251 read=149
Planning Time: 0.438 ms
Execution Time: 24.794 ms
(11 rows)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment