Hello!
We have a single node cluster and about 160,000 documents in our bucket. All of our N1QL queries are running slowly. The following query, although it is fully covered with an index, takes much longer to run than expected (~2 seconds).
The query:
SELECT per.nameFirst, per.nameLast, per.dateOfBirth
FROM deco_db_deco per
WHERE per.type = ‘person’ AND LOWER(per.nameLast) like '%smith%'
ORDER BY per.nameLast desc
Here is the explain:
EXPLAIN:
[
{
“plan”: {
"#operator": “Sequence”,
"~children": [
{
"#operator": “Sequence”,
"~children": [
{
"#operator": “IndexScan”,
“covers”: [
“cover ((per
.type
))”,
“cover ((per
.nameFirst
))”,
“cover ((per
.nameLast
))”,
“cover ((per
.dateOfBirth
))”,
“cover ((per
.ssn
))”,
“cover ((per
.client_ids
))”,
“cover ((per
.address
))”,
“cover ((meta(per
).id
))”,
“cover ((meta(per
).id
))”
],
“filter_covers”: {
“cover ((per
.type
))”: “person”
},
“index”: “search_persons_all_index”,
“index_id”: “9fd4b2dae726acfe”,
“keyspace”: “deco_db_deco”,
“namespace”: “default”,
“spans”: [
{
“Exact”: true,
“Range”: {
“High”: [
“successor(“person”)”
],
“Inclusion”: 1,
“Low”: [
"“person”"
]
}
}
],
“using”: “gsi”
},
{
"#operator": “Parallel”,
"~child": {
"#operator": “Sequence”,
"~children": [
{
"#operator": “Filter”,
“condition”: “((cover ((per
.type
)) = “person”) and (lower(cover ((per
.nameLast
))) like “%smith%”))”
},
{
"#operator": “InitialProject”,
“result_terms”: [
{
“expr”: “cover ((per
.nameFirst
))”
},
{
“expr”: “cover ((per
.nameLast
))”
},
{
“expr”: “cover ((per
.dateOfBirth
))”
}
]
}
]
}
}
]
},
{
"#operator": “Order”,
“sort_terms”: [
{
“desc”: true,
“expr”: “cover ((per
.nameLast
))”
}
]
},
{
"#operator": “FinalProject”
}
]
},
“text”: “SELECT per.nameFirst, per.nameLast, per.dateOfBirth \n\tFROM deco_db_deco per \n\tWHERE per.type = ‘person’ AND LOWER(per.nameLast) like ‘%smith%’\n\tORDER BY per.nameLast desc”
}
]
Does anyone have any thoughts or ideas as to why this seemingly simple and indexed query takes so long to run?
Thanks.