cancel
Showing results for 
Search instead for 
Did you mean: 

Slow NXQL queries

Bertrand_Pestre
Champ in-the-making
Champ in-the-making

I have some NXQL queries that are pretty slow. Using this https://doc.nuxeo.com/nxdoc/monitoring-slow-nxql-queries/ I was able to get some of the slowest NXQL queries This one took 870 ms:

QueryFilter(principal=myOrganisation, limit=0, offset=0) count total results UNLIMITED 
query SELECT * FROM Document 
WHERE (myOrganisation.common:unpublished = 0) 
	AND (ecm:isVersion = 0) 
	AND (myOrganisation.common:removed = 0) 
	AND (dc:source = 'MyOrganisation') 
	AND (myOrganisation.common:migrating = 0) 
	AND (ecm:path STARTSWITH '/default-domain/workspaces/MyOrganisation/organisations/1011/legal' 
		OR ecm:path STARTSWITH '/default-domain/workspaces/MyOrganisation/organisations/1011/business' 
		OR ecm:path STARTSWITH '/default-domain/workspaces/MyOrganisation/organisations/1011/projects/5180')

I notice that the more clauses ecm:path STARTSWITH '/default-domain/workspaces... are present, the slowest is the query. An other similar request with approximately 40 ecm:path STARTSWITH ... clauses took 3200 ms.

Is it a bad practice to write NXQL queries like this ?

1 REPLY 1

Florent_Guillau
World-Class Innovator
World-Class Innovator

Yes it's bad practice because STARTSWITH queries are inherently costly (as you can imagine). You should review your data modeling to make it more amenable to efficient queries.

Getting started

Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.