Description
See the results from UNION ALL when you have WHERE clause and there is an index on that
This does the index scancount... Not sure if it's limited to that.
|
cbq> select sum(cnt) from
|
> (
|
> select count(1) cnt FROM ORDER_LINE
|
> UNION ALL
|
> select count(1) cnt FROM ORDER_LINE
|
> ) as b;
|
{
|
"requestID": "eef240d6-ddad-4b31-b76b-cb57832077ec",
|
"signature": {
|
"$1": "number"
|
},
|
"results": [
|
{
|
"$1": 600046
|
}
|
],
|
"status": "success",
|
"metrics": {
|
"elapsedTime": "9.737953ms",
|
"executionTime": "9.703605ms",
|
"resultCount": 1,
|
"resultSize": 36
|
}
|
}
|
cbq> explain select sum(cnt) from
|
> (
|
> select count(1) cnt FROM ORDER_LINE where junk1 = 'aaaaaa'
|
> UNION ALL
|
> select count(1) cnt FROM ORDER_LINE where junk1 = 'zzzzzz'
|
> ) as b;
|
{
|
"requestID": "524a80d4-9c8f-40ca-8488-66522ba7795c",
|
"signature": "json",
|
"results": [
|
{
|
"plan": {
|
"#operator": "Sequence",
|
"~children": [
|
{
|
"#operator": "UnionAll",
|
"children": [
|
{
|
"#operator": "Sequence",
|
"~children": [
|
{
|
"#operator": "IndexCountScan",
|
"covers": [
|
"cover ((`ORDER_LINE`.`junk1`))",
|
"cover ((meta(`ORDER_LINE`).`id`))"
|
],
|
"index": "i1",
|
"index_id": "3caad6c32a08a9a6",
|
"keyspace": "ORDER_LINE",
|
"namespace": "default",
|
"spans": [
|
{
|
"Range": {
|
"High": [
|
"\"aaaaaa\""
|
],
|
"Inclusion": 3,
|
"Low": [
|
"\"aaaaaa\""
|
]
|
}
|
}
|
],
|
"using": "gsi"
|
},
|
{
|
"#operator": "IndexCountProject",
|
"result_terms": [
|
{
|
"as": "cnt",
|
"expr": "count(1)"
|
}
|
]
|
}
|
]
|
},
|
{
|
"#operator": "Sequence",
|
"~children": [
|
{
|
"#operator": "IndexCountScan",
|
"covers": [
|
"cover ((`ORDER_LINE`.`junk1`))",
|
"cover ((meta(`ORDER_LINE`).`id`))"
|
],
|
"index": "i1",
|
"index_id": "3caad6c32a08a9a6",
|
"keyspace": "ORDER_LINE",
|
"namespace": "default",
|
"spans": [
|
{
|
"Range": {
|
"High": [
|
"\"zzzzzz\""
|
],
|
"Inclusion": 3,
|
"Low": [
|
"\"zzzzzz\""
|
]
|
}
|
}
|
],
|
"using": "gsi"
|
},
|
{
|
"#operator": "IndexCountProject",
|
"result_terms": [
|
{
|
"as": "cnt",
|
"expr": "count(1)"
|
}
|
]
|
}
|
]
|
}
|
]
|
},
|
{
|
"#operator": "Alias",
|
"as": "b"
|
},
|
{
|
"#operator": "IndexCountProject",
|
"result_terms": [
|
{
|
"expr": "sum((`b`.`cnt`))"
|
}
|
]
|
}
|
]
|
},
|
"text": "select sum(cnt) from ( select count(1) cnt FROM ORDER_LINE where junk1 = 'aaaaaa' UNION ALL select count(1) cnt FROM ORDER_LINE where junk1 = 'zzzzzz' ) as b"
|
}
|
],
|
"status": "success",
|
"metrics": {
|
"elapsedTime": "3.013948ms",
|
"executionTime": "2.990442ms",
|
"resultCount": 1,
|
"resultSize": 5121
|
}
|
}
|
|
Attachments
Issue Links
- blocks
-
MB-19612 4.5.1 Minor Release
- Closed