Skip to content

Instantly share code, notes, and snippets.

@jordanlewis
Created February 15, 2019 19:35
Show Gist options
  • Save jordanlewis/e0e33640b2d22e778dba697076ba00cf to your computer and use it in GitHub Desktop.
Save jordanlewis/e0e33640b2d22e778dba697076ba00cf to your computer and use it in GitHub Desktop.
root@127.0.0.1:63435/defaultdb> explain(opt,verbose) SELECT * FROM c WHERE (SELECT min(ship) FROM o WHERE o.c_id=c.c_id) IN (SELECT ship FROM o WHERE o.c_id=c.c_id);
text
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
group-by
├── columns: c_id:1 bill:2
├── grouping columns: c.c_id:1
├── stats: [rows=0.995017125, distinct(1)=0.995017125, null(1)=0]
├── cost: 119547.485
├── key: (1)
├── fd: (1)-->(2)
├── prune: (2)
├── select
│ ├── columns: c.c_id:1 bill:2 ship:5 min:9 rownum:10
│ ├── stats: [rows=1, distinct(1)=0.995017125, null(1)=0, distinct(5)=1, null(5)=0, distinct(9)=1, null(9)=0, distinct(10)=0.999500671, null(10)=0]
│ ├── cost: 119547.435
│ ├── key: (1,10)
│ ├── fd: (1)-->(2), (1,10)-->(2,5,9), (5)==(9), (9)==(5)
│ ├── prune: (2)
│ ├── interesting orderings: (+1)
│ ├── group-by
│ │ ├── columns: c.c_id:1 bill:2 ship:5 min:9 rownum:10
│ │ ├── grouping columns: c.c_id:1 rownum:10
│ │ ├── stats: [rows=990000, distinct(1)=100, null(1)=0, distinct(5)=990000, null(5)=0, distinct(9)=990000, null(9)=0, distinct(10)=1000, null(10)=0, distinct(1,10)=990000, null(1,10)=0]
│ │ ├── cost: 109647.425
│ │ ├── key: (1,10)
│ │ ├── fd: (1)-->(2), (1,10)-->(2,5,9)
│ │ ├── prune: (2,5,9)
│ │ ├── interesting orderings: (+1)
│ │ ├── inner-join-apply
│ │ │ ├── columns: c.c_id:1 bill:2 ship:5 o.c_id:7 ship:8 rownum:10
│ │ │ ├── stats: [rows=990000, distinct(1)=100, null(1)=0, distinct(7)=100, null(7)=0, distinct(8)=100, null(8)=0, distinct(10)=1000, null(10)=0, distinct(1,10)=990000, null(1,10)=0]
│ │ │ ├── cost: 40347.415
│ │ │ ├── fd: (1)-->(2), (1,10)-->(5), (1)==(7), (7)==(1)
│ │ │ ├── prune: (2,5)
│ │ │ ├── interesting orderings: (+1)
│ │ │ ├── scan c
│ │ │ │ ├── columns: c.c_id:1 bill:2
│ │ │ │ ├── stats: [rows=1000, distinct(1)=1000, null(1)=0]
│ │ │ │ ├── cost: 1040.01
│ │ │ │ ├── key: (1)
│ │ │ │ ├── fd: (1)-->(2)
│ │ │ │ ├── prune: (1,2)
│ │ │ │ └── interesting orderings: (+1)
│ │ │ ├── inner-join
│ │ │ │ ├── columns: ship:5 o.c_id:7 ship:8 rownum:10
│ │ │ │ ├── outer: (1)
│ │ │ │ ├── stats: [rows=990000, distinct(7)=100, null(7)=9900, distinct(8)=100, null(8)=0, distinct(10)=1000, null(10)=0]
│ │ │ │ ├── cost: 12069.895
│ │ │ │ ├── fd: (10)-->(5)
│ │ │ │ ├── prune: (5,7)
│ │ │ │ ├── row-number
│ │ │ │ │ ├── columns: ship:5 rownum:10
│ │ │ │ │ ├── outer: (1)
│ │ │ │ │ ├── stats: [rows=1000, distinct(10)=1000, null(10)=0]
│ │ │ │ │ ├── cost: 1080.04
│ │ │ │ │ ├── key: (10)
│ │ │ │ │ ├── fd: (10)-->(5)
│ │ │ │ │ ├── prune: (5)
│ │ │ │ │ └── project
│ │ │ │ │ ├── columns: ship:5
│ │ │ │ │ ├── outer: (1)
│ │ │ │ │ ├── stats: [rows=1000]
│ │ │ │ │ ├── cost: 1070.03
│ │ │ │ │ ├── prune: (5)
│ │ │ │ │ └── select
│ │ │ │ │ ├── columns: o.c_id:4 ship:5
│ │ │ │ │ ├── outer: (1)
│ │ │ │ │ ├── stats: [rows=1000, distinct(1)=1, null(1)=0, distinct(4)=100, null(4)=0]
│ │ │ │ │ ├── cost: 1060.02
│ │ │ │ │ ├── fd: ()-->(4)
│ │ │ │ │ ├── scan o
│ │ │ │ │ │ ├── columns: o.c_id:4 ship:5
│ │ │ │ │ │ ├── stats: [rows=1000, distinct(4)=100, null(4)=10]
│ │ │ │ │ │ ├── cost: 1050.01
│ │ │ │ │ │ └── prune: (4,5)
│ │ │ │ │ └── filters
│ │ │ │ │ └── o.c_id = c.c_id [outer=(1,4), constraints=(/1: (/NULL - ]; /4: (/NULL - ]), fd=(1)==(4), (4)==(1)]
│ │ │ │ ├── select
│ │ │ │ │ ├── columns: o.c_id:7 ship:8
│ │ │ │ │ ├── stats: [rows=990, distinct(7)=100, null(7)=9.9, distinct(8)=100, null(8)=0]
│ │ │ │ │ ├── cost: 1060.02
│ │ │ │ │ ├── prune: (7)
│ │ │ │ │ ├── scan o
│ │ │ │ │ │ ├── columns: o.c_id:7 ship:8
│ │ │ │ │ │ ├── stats: [rows=1000, distinct(7)=100, null(7)=10, distinct(8)=100, null(8)=10]
│ │ │ │ │ │ ├── cost: 1050.01
│ │ │ │ │ │ └── prune: (7,8)
│ │ │ │ │ └── filters
│ │ │ │ │ └── ship IS NOT NULL [outer=(8), constraints=(/8: (/NULL - ]; tight)]
│ │ │ │ └── filters (true)
│ │ │ └── filters
│ │ │ └── o.c_id = c.c_id [outer=(1,7), constraints=(/1: (/NULL - ]; /7: (/NULL - ]), fd=(1)==(7), (7)==(1)]
│ │ └── aggregations
│ │ ├── min [outer=(8)]
│ │ │ └── variable: ship
│ │ ├── const-agg [outer=(5)]
│ │ │ └── variable: ship
│ │ └── const-agg [outer=(2)]
│ │ └── variable: bill
│ └── filters
│ └── ship = min [outer=(5,9), constraints=(/5: (/NULL - ]; /9: (/NULL - ]), fd=(5)==(9), (9)==(5)]
└── aggregations
└── const-agg [outer=(2)]
└── variable: bill
(101 rows)
Time: 11.159ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment