Hi Team,
We are facing issue with one of the query. Its taking more time for its run. Can anyone please provide the alternate query and right index for it.
Below is the query and index currently used:
Query:
SELECT tab.itemNumber, tab.modelId, tab.country, tab.vendorNumber, tab.createdTimeStamp, tab.updateDateTime, tab.docType, tab.createdBy, tab.updateBy, tab.restrictionVersion , ARRAY_AGG(rest) as restrictions FROM bucketA
as tab UNNEST tab.restrictions as rest WHERE tab.createdTimeStamp is not null and rest.beginDate BETWEEN xxxxx AND xxxxx AND tab.docType = ‘xxxx’ GROUP BY tab.itemNumber, tab.modelId, tab.country, tab.vendorNumber, tab.createdTimeStamp, tab.updateDateTime, tab.docType, tab.createdBy, tab.updateBy, tab.restrictionVersion OFFSET 0 LIMIT 2
Index:
CREATE INDEX test ON bucketA
(createdTimeStamp desc,ALL ARRAY rest
.beginDate
FOR rest IN restrictions
END,itemNumber,modelId,country
,vendorNumber
,updateDateTime
,createdBy
,updateBy
,restrictionVersion
) WHERE docType
= ‘xxxxx’ and createdTimeStamp is not null