<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Slow NXQL queries in Nuxeo Forum</title>
    <link>https://connect.hyland.com/t5/nuxeo-forum/slow-nxql-queries/m-p/319729#M6730</link>
    <description>&lt;P&gt;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.&lt;/P&gt;</description>
    <pubDate>Tue, 30 Jul 2019 13:52:02 GMT</pubDate>
    <dc:creator>Florent_Guillau</dc:creator>
    <dc:date>2019-07-30T13:52:02Z</dc:date>
    <item>
      <title>Slow NXQL queries</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/slow-nxql-queries/m-p/319728#M6729</link>
      <description>&lt;P&gt;I have some NXQL queries that are pretty slow. Using this &lt;A href="https://doc.nuxeo.com/nxdoc/monitoring-slow-nxql-queries/" target="test_blank"&gt;https://doc.nuxeo.com/nxdoc/monitoring-slow-nxql-queries/&lt;/A&gt; I was able to get some of the slowest NXQL queries
This one took 870 ms:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;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')
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I notice that the more clauses &lt;CODE&gt;ecm:path STARTSWITH '/default-domain/workspaces...&lt;/CODE&gt; are present, the slowest is the query. An other similar request with approximately 40 &lt;CODE&gt;ecm:path STARTSWITH ...&lt;/CODE&gt; clauses took 3200 ms.&lt;/P&gt;
&lt;P&gt;Is it a bad practice to write NXQL queries like this ?&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jul 2019 15:13:22 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/slow-nxql-queries/m-p/319728#M6729</guid>
      <dc:creator>Bertrand_Pestre</dc:creator>
      <dc:date>2019-07-26T15:13:22Z</dc:date>
    </item>
    <item>
      <title>Re: Slow NXQL queries</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/slow-nxql-queries/m-p/319729#M6730</link>
      <description>&lt;P&gt;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.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jul 2019 13:52:02 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/slow-nxql-queries/m-p/319729#M6730</guid>
      <dc:creator>Florent_Guillau</dc:creator>
      <dc:date>2019-07-30T13:52:02Z</dc:date>
    </item>
  </channel>
</rss>

