Hi
Need help
We have 2 count queries that are taking more time for execution,
We have two clusters one on Enterprise Edition 5.1.0 build 5552 and another on Enterprise Edition 6.0.2 build 2413 and both the clusters are with 7 nodes(3 data, 2 index and 2 query nodes)
There are around 20 million documents in the bucket that is being queried.
However, queries are taking more than 1 min to execute and the results are same in both the clusters.
PFB queries
Query:
SELECT count(*) FROM promotions commandStatus UNNEST commandStatus.migrations as migrations
WHERE commandStatus._class
= “com.tesco.api.promotion.domain.commandStatus.LegacyCommandStatus”
AND migrations.status = “ERROR”
AND commandStatus.messageId LIKE “%PR%”
AND commandStatus.createdDateTime BETWEEN 1554536717000 AND 1586159117000
Index:
CREATE INDEX legacy_ALL_migrations_createdDateTime_messageId
ON promotions
(ALL migrations
,createdDateTime
,messageId
)
WHERE _class
= ‘com.tesco.api.promotion.domain.commandStatus.LegacyCommandStatus’
using GSI WITH {“num_replica”: 1};
Explain:
{
"plan": {
"#operator": "Sequence",
"~children": [
{
"#operator": "IndexCountScan2",
"covers": [
"cover ((`migrations`.`status`))",
"cover ((`commandStatus`.`createdDateTime`))",
"cover ((`commandStatus`.`messageId`))",
"cover ((meta(`commandStatus`).`id`))"
],
"filter_covers": {
"cover (((`commandStatus`.`migrations`) < {}))": true,
"cover (([] <= (`commandStatus`.`migrations`)))": true,
"cover ((`commandStatus`.`_class`))": "com.tesco.api.promotion.domain.commandStatus.LegacyCommandStatus",
"cover (is_array((`commandStatus`.`migrations`)))": true
},
"index": "legacy_ALL_migrations_status_createdDateTime_messageId",
"index_id": "1db88738656eaea3",
"keyspace": "promotions",
"namespace": "default",
"spans": [
{
"exact": true,
"range": [
{
"high": "\"ERROR\"",
"inclusion": 3,
"low": "\"ERROR\""
}
]
}
],
"using": "gsi"
},
{
"#operator": "IndexCountProject",
"result_terms": [
{
"expr": "count(*)"
}
]
}
]
},
"text": "SELECT count(*) FROM promotions commandStatus UNNEST commandStatus.migrations as migrations \nWHERE commandStatus.`_class` = \"com.tesco.api.promotion.domain.commandStatus.LegacyCommandStatus\" \nAND migrations.status = \"ERROR\" \nAND commandStatus.messageId LIKE \"%PR%\"\nAND commandStatus.createdDateTime BETWEEN 1554536717000 AND 1586159117000"
}
Query:
SELECT count(distinct(commandStatus.extId)) FROM promotions commandStatus
WHERE _class
= “com.tesco.api.promotion.domain.commandStatus.LegacyCommandStatus”
AND commandStatus.createdDateTime BETWEEN 1554536717000 AND 1586159117000
Index:
CREATE INDEX legacy_createdDateTime_extId ON promotions
(createdDateTime
,extId
)
WHERE _class
= ‘com.tesco.api.promotion.domain.commandStatus.LegacyCommandStatus’
using GSI WITH {“num_replica”: 1};
Explain:
{
"plan": {
"#operator": "Sequence",
"~children": [
{
"#operator": "IndexScan2",
"covers": [
"cover ((`commandStatus`.`createdDateTime`))",
"cover ((`commandStatus`.`extId`))",
"cover ((meta(`commandStatus`).`id`))"
],
"filter_covers": {
"cover ((`commandStatus`.`_class`))": "com.tesco.api.promotion.domain.commandStatus.LegacyCommandStatus"
},
"index": "legacy_createdDateTime_extId",
"index_id": "42dd1218a78b94fb",
"index_projection": {
"entry_keys": [
0,
1
]
},
"keyspace": "promotions",
"namespace": "default",
"spans": [
{
"exact": true,
"range": [
{
"high": "1586159117000",
"inclusion": 3,
"low": "1554536717000"
},
{
"inclusion": 0,
"low": "null"
}
]
}
],
"using": "gsi"
},
{
"#operator": "Parallel",
"~child": {
"#operator": "Sequence",
"~children": [
{
"#operator": "Filter",
"condition": "((cover ((`commandStatus`.`_class`)) = \"com.tesco.api.promotion.domain.commandStatus.LegacyCommandStatus\") and (cover ((`commandStatus`.`createdDateTime`)) between 1554536717000 and 1586159117000))"
},
{
"#operator": "InitialGroup",
"aggregates": [
"count(distinct cover ((`commandStatus`.`extId`)))"
],
"group_keys": []
}
]
}
},
{
"#operator": "IntermediateGroup",
"aggregates": [
"count(distinct cover ((`commandStatus`.`extId`)))"
],
"group_keys": []
},
{
"#operator": "FinalGroup",
"aggregates": [
"count(distinct cover ((`commandStatus`.`extId`)))"
],
"group_keys": []
},
{
"#operator": "Parallel",
"~child": {
"#operator": "Sequence",
"~children": [
{
"#operator": "InitialProject",
"result_terms": [
{
"expr": "count(distinct cover ((`commandStatus`.`extId`)))"
}
]
},
{
"#operator": "FinalProject"
}
]
}
}
]
},
"text": "SELECT count(distinct(commandStatus.extId)) FROM promotions commandStatus \nWHERE `_class` = \"com.tesco.api.promotion.domain.commandStatus.LegacyCommandStatus\" \nAND commandStatus.createdDateTime BETWEEN 1554536717000 AND 1586159117000"
}
Regards,
Venkat