CB 6 CC index time out even if I change it to an hour

I have 63M docs, each doc - 300 bytes, meta is about 100 bytes
I have what I think are correct indexes however the query keeps failing even after and hour.

indexer log shows no errors
indexer RAM (4GB) is at about 80%
CPU never spikes over 40-50
Buckets Operations Per Second during query - 15k
I am banging my head with this for several days now, nothing I did help, maybe this is too much for CB to take? can some one help me out here?
thanks
Shay

  • query and plan below:
    SELECT
    field,
    dsid,
    Sum(counter) AS count,
    Sum(rvalues) AS rvalues
    FROM metrics
    WHERE field IS NOT missing
    AND dsid IS NOT missing
    AND systemId = ‘configtest’
    and metricType = ‘field’
    GROUP BY
    subField,
    field,
    dsid

this is the execution plan -
{
“plan”: {
#operator”: “Sequence”,
“~children”: [
{
#operator”: “IntersectScan”,
“scans”: [
{
#operator”: “IndexScan3”,
“index”: “metric_job_systemId”,
“index_id”: “3444774e726bad02”,
“index_projection”: {
“primary_key”: true
},
“keyspace”: “metrics”,
“namespace”: “default”,
“spans”: [
{
“exact”: true,
“range”: [
{
“high”: ““configtest””,
“inclusion”: 3,
“low”: ““configtest””
}
]
}
],
“using”: “gsi”
},
{
#operator”: “IndexScan3”,
“index”: “metric_job_metricType”,
“index_id”: “443efd32ef30652d”,
“index_projection”: {
“primary_key”: true
},
“keyspace”: “metrics”,
“namespace”: “default”,
“spans”: [
{
“exact”: true,
“range”: [
{
“high”: ““field””,
“inclusion”: 3,
“low”: ““field””
}
]
}
],
“using”: “gsi”
}
]
},
{
#operator”: “Fetch”,
“keyspace”: “metrics”,
“namespace”: “default”
},
{
#operator”: “Parallel”,
“~child”: {
#operator”: “Sequence”,
“~children”: [
{
#operator”: “Filter”,
“condition”: “(((((metrics.field) is not missing) and ((metrics.dsid) is not missing)) and ((metrics.systemId) = “configtest”)) and ((metrics.metricType) = “field”))”
},
{
#operator”: “InitialGroup”,
“aggregates”: [
“sum((metrics.counter))”,
“sum((metrics.rvalues))”
],
“group_keys”: [
“(metrics.subField)”,
“(metrics.field)”,
“(metrics.dsid)”
]
}
]
}
},
{
#operator”: “IntermediateGroup”,
“aggregates”: [
“sum((metrics.counter))”,
“sum((metrics.rvalues))”
],
“group_keys”: [
“(metrics.subField)”,
“(metrics.field)”,
“(metrics.dsid)”
]
},
{
#operator”: “FinalGroup”,
“aggregates”: [
“sum((metrics.counter))”,
“sum((metrics.rvalues))”
],
“group_keys”: [
“(metrics.subField)”,
“(metrics.field)”,
“(metrics.dsid)”
]
},
{
#operator”: “Parallel”,
“~child”: {
#operator”: “Sequence”,
“~children”: [
{
#operator”: “InitialProject”,
“result_terms”: [
{
“expr”: “(metrics.field)”
},
{
“expr”: “(metrics.dsid)”
},
{
“as”: “count”,
“expr”: “sum((metrics.counter))”
},
{
“as”: “rvalues”,
“expr”: “sum((metrics.rvalues))”
}
]
},
{
#operator”: “FinalProject”
}
]
}
}
]
},
“text”: “SELECT field, \n dsid, \n Sum(counter) AS count, \n Sum(rvalues) AS rvalues \nFROM metrics \n\nWHERE field IS NOT missing \nAND dsid IS NOT missing \nAND systemId = ‘configtest’\nand metricType = ‘field’\nGROUP BY \nsubField,\nfield, \ndsid”
}

Please post the create index statement. Plan doesn’t look optimal as query engine is doing Fetch. Try to create a covering index and see how that goes:

https://blog.couchbase.com/create-right-index-get-right-performance/

CREATE INDEX ix1 ON metrics(systemId, field,  dsid, subField, counter,  rvalues)
 WHERE  metricType = ‘field’;

Try above index. As you have 63M docs and doing aggregates try set max_parallelism to 4

Also try with 6.0 EE

Hi, I create the above index , now the execution plan looks better but I still get time outs, I added a limit to see if that helps but it didn’t
unfortunately using EE is not yet an option…
{
“plan”: {
#operator”: “Sequence”,
“~children”: [
{
#operator”: “Sequence”,
“~children”: [
{
#operator”: “IndexScan3”,
“covers”: [
“cover ((metrics.systemId))”,
“cover ((metrics.field))”,
“cover ((metrics.dsid))”,
“cover ((metrics.subField))”,
“cover ((metrics.counter))”,
“cover ((metrics.rvalues))”,
“cover ((meta(metrics).id))”
],
“filter_covers”: {
“cover ((metrics.metricType))”: “field”
},
“index”: “ix1”,
“index_id”: “3ae22992104540c0”,
“index_projection”: {
“entry_keys”: [
0,
1,
2,
3,
4,
5
]
},
“keyspace”: “metrics”,
“namespace”: “default”,
“spans”: [
{
“exact”: true,
“range”: [
{
“high”: ““configtest””,
“inclusion”: 3,
“low”: ““configtest””
},
{
“inclusion”: 1,
“low”: “null”
},
{
“inclusion”: 1,
“low”: “null”
}
]
}
],
“using”: “gsi”
},
{
#operator”: “Parallel”,
“~child”: {
#operator”: “Sequence”,
“~children”: [
{
#operator”: “Filter”,
“condition”: “((((cover ((metrics.field)) is not missing) and (cover ((metrics.dsid)) is not missing)) and (cover ((metrics.systemId)) = “configtest”)) and (cover ((metrics.metricType)) = “field”))”
},
{
#operator”: “InitialGroup”,
“aggregates”: [
“sum(cover ((metrics.counter)))”,
“sum(cover ((metrics.rvalues)))”
],
“group_keys”: [
“cover ((metrics.subField))”,
“cover ((metrics.field))”,
“cover ((metrics.dsid))”
]
}
]
}
},
{
#operator”: “IntermediateGroup”,
“aggregates”: [
“sum(cover ((metrics.counter)))”,
“sum(cover ((metrics.rvalues)))”
],
“group_keys”: [
“cover ((metrics.subField))”,
“cover ((metrics.field))”,
“cover ((metrics.dsid))”
]
},
{
#operator”: “FinalGroup”,
“aggregates”: [
“sum(cover ((metrics.counter)))”,
“sum(cover ((metrics.rvalues)))”
],
“group_keys”: [
“cover ((metrics.subField))”,
“cover ((metrics.field))”,
“cover ((metrics.dsid))”
]
},
{
#operator”: “Parallel”,
“~child”: {
#operator”: “Sequence”,
“~children”: [
{
#operator”: “InitialProject”,
“result_terms”: [
{
“expr”: “cover ((metrics.field))”
},
{
“expr”: “cover ((metrics.dsid))”
},
{
“as”: “count”,
“expr”: “sum(cover ((metrics.counter)))”
},
{
“as”: “rvalues”,
“expr”: “sum(cover ((metrics.rvalues)))”
}
]
},
{
#operator”: “FinalProject”
}
]
}
}
]
},
{
#operator”: “Limit”,
“expr”: “10”
}
]
},
“text”: “SELECT\nfield,\ndsid,\nSum(counter) AS count,\nSum(rvalues) AS rvalues\nFROM metrics\nWHERE field IS NOT missing\nAND dsid IS NOT missing\nAND systemId = “configtest”\nand metricType = “field”\nGROUP BY\nsubField,\nfield,\ndsid\nlimit 10”
}

GROUP BY/Aggregation is blocking operations (Needs group /aggregate all results first). That is taking time .

So it makes sense that it takes over an hour for 63M records? Maybe CB is the wrong choice here?

From the in-house benchmark, 10M records can be aggregated in 11seconds using partitioned index(8 partitions with EE storage engine) and aggregate pushdown e.g. see AG4 partitioned in:
http://showfast.sc.couchbase.com/#/timeline/Linux/n1ql/aggregation/Latency