GraphQL query shows up in Query Recorder logs with large scans, but the query should be performant
We have some GraphQL persisted queries that show up in the AEM Query Recorder logs as having large scans to return a single result. Here’s an example of what we see in the logs.
[72.135.49.53 [1773258109390] POST /graphql/execute.json/mycompany/getProductDetails HTTP/1.1] org.apache.jackrabbit.oak.query.stats.QueryRecorder count: 2400 query: SELECT main.* FROM [dam:IndexedFragmentData] AS main WHERE ISDESCENDANTNODE(main, 'x') AND main.[@string@model] = 'x' AND (name(main) = 'x') AND ((ISDESCENDANTNODE(main, 'x')) AND (main.[string@serviceCode] = 'x') AND (main.[jcr:primaryType] IS NOT NULL) AND (main.[jcr:primaryType] IS NOT NULL) AND (main.[jcr:primaryType] IS NOT NULL)) ORDER BY main.[jcr:path] OPTION (INDEX TAG[contentFragments], TRAVERSAL FAIL)What’s jumping out to me is the “QueryRecorder count: 2400” when there is only 1 record returned. And when I run the same query locally and look at its performance in the Query Performance tool it shows as scanning only 1 row. So I’m wondering how this could happen. Any help would be appreciated as we don’t have access to the Query Performance tools on Publish in Cloud environments. I have opened a ticket with Adobe as well, but I’m curious if anyone has seen this.