Disable unique results:

ARTIFACTORY: What can be done in case of slow AQL queries?

AuthorFullName__c
Elina Floim
articleNumber
000005603
ft:sourceType
Salesforce
FirstPublishedDate
2023-03-06T12:32:23Z
lastModifiedDate
2023-03-06
VersionNumber
1
AQL queries are translated to SQL queries behind the scenes. By default, AQL queries are executed with SELECT DISTINCT as the default value of distinct is true. This parameter enables/disables unique query results and is available from Artifactory version 7.37. This can be used to speed up the query or to get the results "as is". In order to set the distinct value of the query to ‘false’, the parameter should be added to the query itself. For example:
items.find({"name" : {"$match":"*.jar"}}).include("name").distinct(false)

In case the above suggestions do not improve the query’s performance, the slowness of the query may originate in the database. To validate the case, we recommend consulting with your organization’s DBA in order to inspect the query on the database side - reviewing the query execution plan, making sure that the indexes are valid, and looking into the fragmentation.