Hi Team,
I am working on query optimization for one of my query . I am trying to push down the group by operation to be performed by the index node rather than query node.
I have given the info needed below.
Primary key : EMP:ACCT#1
document:
{
“name”: “user1”,
“type”: “ACCOUNTS_EMPLOYEE”,
“age”: 27,
“title”: “SENIOR_ACCOUNTANT”
}
Index:
CREATE INDEX emp_bucket_acct_emp
ON EMP_BUCKET
(title
,name
,age
) WHERE (type
= “ACCOUNTS_EMPLOYEE”)
$names is just a variable.
When the condition is c.name = $names , the group by is performed by index node but when I use AND c.name in $names , the group by is performed by query node.
SELECT c.title,
COUNT(title) AS count
FROM BNE_TRAFFIC AS c
WHERE c.type=“ACCOUNTS_EMPLOYEE”
AND c.title IS NOT MISSING
AND c.name = $names
AND c.age >= 28
AND c.age <= 45
GROUP BY title
SELECT c.title,
COUNT(title) AS count
FROM BNE_TRAFFIC AS c
WHERE c.type=“ACCOUNTS_EMPLOYEE”
AND c.title IS NOT MISSING
AND c.name in $names
AND c.age >= 28
AND c.age <= 45
GROUP BY title
Kindly let me know how to make the index node do the group by in case of above query.
Or if this is not possible, how to change the IN condition so as to make the above optimization possible