Skip to content

Instantly share code, notes, and snippets.

@nileema
Created August 28, 2014 19:37
Show Gist options
  • Save nileema/9c1dff227b550969e184 to your computer and use it in GitHub Desktop.
Save nileema/9c1dff227b550969e184 to your computer and use it in GitHub Desktop.
presto:tiny> explain SELECT * FROM (SELECT row_number() over() rn, orderkey, orderstatus, custkey from orders) where rn < 10
-> ;
Query Plan
--------------------------------------------------------------------------------------------------------------------------------------
- Output[rn, orderkey, orderstatus, custkey]
rn := row_1
- Filter[("row_1" < 10)] => [orderkey:bigint, custkey:bigint, orderstatus:varchar, row_1:bigint]
- RowNumber[] => [orderkey:bigint, custkey:bigint, orderstatus:varchar, row_1:bigint]
row_1 := row_number()
- TableScan[tpch:tpch:orders:sf0.01, original constraint=true] => [orderkey:bigint, custkey:bigint, orderstatus:varchar]
orderkey := tpch:tpch:orderkey:0
custkey := tpch:tpch:custkey:1
orderstatus := tpch:tpch:orderstatus:2
(1 row)
Query 20140828_193624_00004_zwt29, FINISHED, 1 node
Splits: 1 total, 1 done (100.00%)
0:00 [1 rows, 635B] [19 rows/s, 11.9KB/s]
presto:tiny> explain SELECT * FROM (SELECT row_number() over(partition by orderstatus) rn, orderkey, orderstatus, custkey from orders) where rn < 10
-> ;
Query Plan
--------------------------------------------------------------------------------------------------------------------------------------
- Output[rn, orderkey, orderstatus, custkey]
rn := row_1
- Filter[("row_1" < 10)] => [orderkey:bigint, custkey:bigint, orderstatus:varchar, row_1:bigint]
- RowNumber[partition by (orderstatus)] => [orderkey:bigint, custkey:bigint, orderstatus:varchar, row_1:bigint]
row_1 := row_number()
- TableScan[tpch:tpch:orders:sf0.01, original constraint=true] => [orderkey:bigint, custkey:bigint, orderstatus:varchar]
orderkey := tpch:tpch:orderkey:0
custkey := tpch:tpch:custkey:1
orderstatus := tpch:tpch:orderstatus:2
(1 row)
Query 20140828_193652_00005_zwt29, FINISHED, 1 node
Splits: 1 total, 1 done (100.00%)
0:00 [1 rows, 661B] [37 rows/s, 24.3KB/s]
presto:tiny> explain SELECT * FROM (SELECT row_number() over(order by orderkey) rn, orderkey, orderstatus, custkey from orders) where rn < 10
-> ;
Query Plan
---------------------------------------------------------------------------------------------------------------------------------------------
- Output[rn, orderkey, orderstatus, custkey]
rn := row_1
- TopNRowNumber[partition by (), order by (orderkey ASC_NULLS_LAST) N(9)] => [orderkey:bigint, custkey:bigint, orderstatus:varchar, row_
row_1 := row_number()
- TableScan[tpch:tpch:orders:sf0.01, original constraint=true] => [orderkey:bigint, custkey:bigint, orderstatus:varchar]
orderkey := tpch:tpch:orderkey:0
custkey := tpch:tpch:custkey:1
orderstatus := tpch:tpch:orderstatus:2
(1 row)
Query 20140828_193659_00006_zwt29, FINISHED, 1 node
Splits: 1 total, 1 done (100.00%)
0:07 [1 rows, 570B] [0 rows/s, 82B/s]
presto:tiny> explain SELECT * FROM (SELECT row_number() over(partition by orderstatus order by orderkey) rn, orderkey, orderstatus, custkey from orders) where rn < 10
-> ;
Query Plan
---------------------------------------------------------------------------------------------------------------------------------------------
- Output[rn, orderkey, orderstatus, custkey]
rn := row_1
- TopNRowNumber[partition by (orderstatus), order by (orderkey ASC_NULLS_LAST) N(9)] => [orderkey:bigint, custkey:bigint, orderstatus:va
row_1 := row_number()
- TableScan[tpch:tpch:orders:sf0.01, original constraint=true] => [orderkey:bigint, custkey:bigint, orderstatus:varchar]
orderkey := tpch:tpch:orderkey:0
custkey := tpch:tpch:custkey:1
orderstatus := tpch:tpch:orderstatus:2
(1 row)
Query 20140828_193710_00007_zwt29, FINISHED, 1 node
Splits: 1 total, 1 done (100.00%)
0:19 [1 rows, 581B] [0 rows/s, 31B/s]
presto:tiny> explain SELECT * FROM (SELECT row_number() over(partition by orderstatus order by orderkey) rn, orderkey, orderstatus, custkey from orders) limit 10;
Query Plan
---------------------------------------------------------------------------------------------------------------------------------------------
- Output[rn, orderkey, orderstatus, custkey]
rn := row_1
- TopNRowNumber[partition by (orderstatus), order by (orderkey ASC_NULLS_LAST) N(10)] => [orderkey:bigint, custkey:bigint, orderstatus:v
row_1 := row_number()
- TableScan[tpch:tpch:orders:sf0.01, original constraint=true] => [orderkey:bigint, custkey:bigint, orderstatus:varchar]
orderkey := tpch:tpch:orderkey:0
custkey := tpch:tpch:custkey:1
orderstatus := tpch:tpch:orderstatus:2
(1 row)
Query 20140828_193738_00008_zwt29, FINISHED, 1 node
Splits: 1 total, 1 done (100.00%)
0:04 [1 rows, 582B] [0 rows/s, 163B/s]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment