Skip to content

Instantly share code, notes, and snippets.

@tayl0r
Created June 26, 2014 20:22
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 tayl0r/66299f41f530c8c881c5 to your computer and use it in GitHub Desktop.
Save tayl0r/66299f41f530c8c881c5 to your computer and use it in GitHub Desktop.
redshift wtf explain plan
10 second query:
XN Merge (cost=1000000000000.07..1000000000000.07 rows=1 width=76)
-> XN Network (cost=1000000000000.07..1000000000000.07 rows=1 width=76)
-> XN Sort (cost=1000000000000.07..1000000000000.07 rows=1 width=76)
-> XN HashAggregate (cost=0.05..0.06 rows=1 width=76)
-> XN Subquery Scan volt_dt_0 (cost=0.04..0.05 rows=1 width=76)
-> XN HashAggregate (cost=0.04..0.04 rows=1 width=76)
-> XN Subquery Scan derived_table1 (cost=0.02..0.03 rows=1 width=76)
-> XN HashAggregate (cost=0.02..0.02 rows=1 width=44)
-> XN Seq Scan on user_events (cost=0.00..0.01 rows=1 width=44)
09 minute query:
XN Merge (cost=1000000000000.13..1000000000000.14 rows=1 width=76)
-> XN Network (cost=1000000000000.13..1000000000000.14 rows=1 width=76)
-> XN Sort (cost=1000000000000.13..1000000000000.14 rows=1 width=76)
-> XN HashAggregate (cost=0.12..0.12 rows=1 width=76)
-> XN Subquery Scan volt_dt_0 (cost=0.10..0.11 rows=1 width=76)
-> XN HashAggregate (cost=0.10..0.10 rows=1 width=76)
-> XN Subquery Scan derived_table1 (cost=0.09..0.10 rows=1 width=76)
-> XN HashAggregate (cost=0.09..0.09 rows=1 width=44)
-> XN Seq Scan on user_events (cost=0.00..0.08 rows=1 width=44)
identical explain plans with the exception of "cost".
fast = XN Seq Scan on user_events (cost=0.00..0.01 rows=1 width=44)
slow = XN Seq Scan on user_events (cost=0.00..0.08 rows=1 width=44)
@Dmitrii-I
Copy link

What are the SQL queries? What are the data types? I experienced much faster hashing of integers compared to varchar.

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