Created
June 7, 2012 08:30
-
-
Save sitharus/2887417 to your computer and use it in GitHub Desktop.
Query Plans
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=# explain update messages set notified = false where NOT EXISTS(SELECT * FROM users u INNER JOIN devices d ON u.id = d.user_id WHERE u.id = messages.user_id); | |
QUERY PLAN | |
------------------------------------------------------------------------------------- | |
Hash Anti Join (cost=305.05..9400.07 rows=1 width=219) | |
Hash Cond: (messages.user_id = u.id) | |
-> Seq Scan on messages (cost=0.00..8219.35 rows=175135 width=219) | |
-> Hash (cost=279.28..279.28 rows=2061 width=4) | |
-> Hash Join (cost=86.37..279.28 rows=2061 width=4) | |
Hash Cond: (u.id = d.user_id) | |
-> Seq Scan on users u (cost=0.00..156.20 rows=3220 width=4) | |
-> Hash (cost=60.61..60.61 rows=2061 width=4) | |
-> Seq Scan on devices d (cost=0.00..60.61 rows=2061 width=4) | |
(9 rows) | |
=# explain update messages set notified = false FROM users u INNER JOIN devices d ON u.id = d.user_id WHERE u.id = messages.user_id; | |
QUERY PLAN | |
------------------------------------------------------------------------------------- | |
Hash Join (cost=305.05..10521.04 rows=175135 width=219) | |
Hash Cond: (messages.user_id = u.id) | |
-> Seq Scan on messages (cost=0.00..8219.35 rows=175135 width=219) | |
-> Hash (cost=279.28..279.28 rows=2061 width=8) | |
-> Hash Join (cost=86.37..279.28 rows=2061 width=8) | |
Hash Cond: (u.id = d.user_id) | |
-> Seq Scan on users u (cost=0.00..156.20 rows=3220 width=4) | |
-> Hash (cost=60.61..60.61 rows=2061 width=4) | |
-> Seq Scan on devices d (cost=0.00..60.61 rows=2061 width=4) | |
(9 rows) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment