Skip to content

Instantly share code, notes, and snippets.

@nileema
Created October 7, 2014 19:59
Show Gist options
  • Save nileema/c45010d1b76d3e39c5f2 to your computer and use it in GitHub Desktop.
Save nileema/c45010d1b76d3e39c5f2 to your computer and use it in GitHub Desktop.
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) , limit (9) ] => [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 20141007_194927_00003_i7qnv, FINISHED, 1 node
Splits: 1 total, 1 done (100.00%)
0:00 [1 rows, 674B] [36 rows/s, 24.2KB/s]
presto:tiny> explain SELECT * FROM (SELECT row_number() over(partition by orderstatus) rn, orderkey, orderstatus, custkey from orders) limit 10;
Query Plan
-----------------------------------------------------------------------------------------------------------------------------------
- Output[rn, orderkey, orderstatus, custkey]
rn := row_1
- RowNumber[partition by (orderstatus) , limit (10) ] => [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 20141007_194935_00004_i7qnv, FINISHED, 1 node
Splits: 1 total, 1 done (100.00%)
0:00 [1 rows, 550B] [41 rows/s, 22.2KB/s]
presto:tiny>
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) limit 9] => [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 20141007_194947_00005_i7qnv, FINISHED, 1 node
Splits: 1 total, 1 done (100.00%)
0:00 [1 rows, 573B] [41 rows/s, 23.2KB/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) limit 9] => [orderkey:bigint, custkey:bigint, orderstatus:varchar, row_1:b
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 20141007_195012_00006_i7qnv, FINISHED, 1 node
Splits: 1 total, 1 done (100.00%)
0:17 [1 rows, 584B] [0 rows/s, 33B/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) limit 10] => [orderkey:bigint, custkey:bigint, orderstatus:varchar, row_1:
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 20141007_195038_00007_i7qnv, FINISHED, 1 node
Splits: 1 total, 1 done (100.00%)
0:08 [1 rows, 585B] [0 rows/s, 75B/s]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment