DQL language syntax for displaying the execution plan produced by the query planner for a statement.
EXPLAIN SELECT * FROM test;
{
"plan": {
"#operator": "sequence",
"children": [
{
"#operator": "scan",
"alias": "test",
"collection": "test",
"datasource": "default",
"descriptor": {
"path": {
"full_scan": {}
}
}
},
{
"#operator": "projection",
"projections": [
{
"expression": "`test`",
"wildcard": true
}
]
}
]
}
}
EXPLAIN
SELECT field3,count(*) the_count
FROM test
WHERE (field1 = 1 AND field2 = 2)
OR (field1 = 2 AND field2 = 1)
GROUP BY field3
ORDER BY the_count DESC
{
"plan": {
"#operator": "sequence",
"children": [
{
"#operator": "unionScan",
"children": [
{
"#operator": "intersectScan",
"children": [
{
"#operator": "indexScan",
"alias": "test",
"collection": "test",
"datasource": "default",
"desc": {
"index": "ix1",
"spans": [
{
"index_key": {
"direction": "asc",
"include_missing": true,
"key": [
"field1"
]
},
"range": {
"high": {
"included": true,
"value": 1
},
"low": {
"included": true,
"value": 1
}
}
}
]
}
},
{
"#operator": "indexScan",
"alias": "test",
"collection": "test",
"datasource": "default",
"desc": {
"index": "ix2",
"spans": [
{
"index_key": {
"direction": "asc",
"include_missing": true,
"key": [
"field2"
]
},
"range": {
"high": {
"included": true,
"value": 2
},
"low": {
"included": true,
"value": 2
}
}
}
]
}
}
]
},
{
"#operator": "intersectScan",
"children": [
{
"#operator": "indexScan",
"alias": "test",
"collection": "test",
"datasource": "default",
"desc": {
"index": "ix1",
"spans": [
{
"index_key": {
"direction": "asc",
"include_missing": true,
"key": [
"field1"
]
},
"range": {
"high": {
"included": true,
"value": 2
},
"low": {
"included": true,
"value": 2
}
}
}
]
}
},
{
"#operator": "indexScan",
"alias": "test",
"collection": "test",
"datasource": "default",
"desc": {
"index": "ix2",
"spans": [
{
"index_key": {
"direction": "asc",
"include_missing": true,
"key": [
"field2"
]
},
"range": {
"high": {
"included": true,
"value": 1
},
"low": {
"included": true,
"value": 1
}
}
}
]
}
}
]
}
]
},
{
"#operator": "fetch",
"alias": "test",
"collection": "test",
"datasource": "default"
},
{
"#operator": "filter",
"condition": "(((`test`.`field1` = 1) AND (`test`.`field2` = 2)) OR ((`test`.`field1` = 2) AND (`test`.`field2` = 1)))"
},
{
"#operator": "groupBy",
"aggregates": [
{
"expr": "true",
"name": "count(true)"
}
],
"keys": [
{
"alias": "$$(group_by_key_1)$$",
"expression": "`test`.`field3`"
}
]
},
{
"#operator": "projection",
"projections": [
{
"alias": "field3",
"expression": "`$$(group_by_key_1)$$`"
},
{
"alias": "the_count",
"expression": "count(true)"
}
]
},
{
"#operator": "sort",
"orderBy": [
{
"direction": "desc",
"key": "`$$(projection)$$`.`the_count`"
}
]
},
{
"#operator": "finalProjection"
}
]
}
}
Was this page helpful?