Skip to content

Instantly share code, notes, and snippets.

@mk270
Created January 5, 2013 14:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mk270/4461924 to your computer and use it in GitHub Desktop.
Save mk270/4461924 to your computer and use it in GitHub Desktop.
compare EXPLAIN UPDATE
without indices
Hash Join (cost=13973.56..43799.18 rows=31766 width=583)
Hash Cond: ((p."globalSchemeId")::text = (s."GlobalSchemeId")::text)
-> Hash Join (cost=13963.11..43034.28 rows=31766 width=579)
Hash Cond: ((p."countryPayment")::text = (c.code)::text)
-> Hash Join (cost=13955.08..42271.81 rows=31766 width=575)
Hash Cond: ((p."globalRecipientId")::text = (r."globalRecipientId")::text)
-> Seq Scan on payment p (cost=0.00..18317.68 rows=860568 width=571)
-> Hash (cost=13784.48..13784.48 rows=13648 width=13)
-> Seq Scan on recipient r (cost=0.00..13784.48 rows=13648 width=13)
-> Hash (cost=4.68..4.68 rows=268 width=7)
-> Seq Scan on country c (cost=0.00..4.68 rows=268 width=7)
-> Hash (cost=10.20..10.20 rows=20 width=222)
-> Seq Scan on scheme s (cost=0.00..10.20 rows=20 width=222)
with indices
Hash Join (cost=25553.80..226914.68 rows=860568 width=583)
Hash Cond: ((p."globalSchemeId")::text = (s."GlobalSchemeId")::text)
-> Hash Join (cost=25552.62..206475.01 rows=860568 width=579)
Hash Cond: ((p."globalRecipientId")::text = (r."globalRecipientId")::text)
-> Hash Join (cost=8.03..38764.20 rows=860568 width=575)
Hash Cond: ((p."countryPayment")::text = (c.code)::text)
-> Seq Scan on payment p (cost=0.00..18317.68 rows=860568 width=571)
-> Hash (cost=4.68..4.68 rows=268 width=7)
-> Seq Scan on country c (cost=0.00..4.68 rows=268 width=7)
-> Hash (cost=17992.26..17992.26 rows=434426 width=13)
-> Seq Scan on recipient r (cost=0.00..17992.26 rows=434426 width=13)
-> Hash (cost=1.08..1.08 rows=8 width=222)
-> Seq Scan on scheme s (cost=0.00..1.08 rows=8 width=222)
@mk270
Copy link
Author

mk270 commented Jan 5, 2013

The difference was:

create index scheme_global_scheme_id_idx on scheme("GlobalSchemeId");
create index recipient_global_recipient_id_idx on recipient("globalRecipientId");
create index country_code_idx on country(code);
create index gri_idx on payment("globalRecipientId");

@pudo
Copy link

pudo commented Jan 5, 2013

Can you post the exact query you executed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment