<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">On 1/3/13 1:50 PM, Claudiu Saftoiu
      wrote:<br>
    </div>
    <blockquote
cite="mid:CAGJ7VxGigSHE-mfA231Gkqiz0X2FGBqDbcNiVfOi5X=Exd7BMw@mail.gmail.com"
      type="cite">
      <div>Hello all,</div>
      <div><br>
      </div>
      Am I doing something wrong with my queries, or is
      repoze.catalog.query very slow?
      <div><br>
      </div>
      <div>I have a `Catalog` with ~320,000 objects and 17
        `CatalogFieldIndex`es. All the objects are indexed and up to
        date. This is the query I ran (field names renamed):</div>
      <div><br>
      </div>
      <div><font face="courier new, monospace">&nbsp; &nbsp;
          And(InRange('float_field', 0.01, 0.04),</font></div>
      <div><font face="courier new, monospace">&nbsp; &nbsp; &nbsp; &nbsp;
          InRange('datetime_field', seven_days_ago, today),</font></div>
      <div><font face="courier new, monospace">&nbsp; &nbsp; &nbsp; &nbsp; Eq('str1', str1),</font></div>
      <div>
        <div><font face="courier new, monospace">&nbsp; &nbsp; &nbsp; &nbsp; Eq('str2',
            str2),</font></div>
      </div>
      <div>
        <div><font face="courier new, monospace">&nbsp; &nbsp; &nbsp; &nbsp; Eq('str3',
            str3),</font></div>
      </div>
      <div>
        <div><font face="courier new, monospace">&nbsp; &nbsp; &nbsp; &nbsp; Eq('str4',
            str4))</font></div>
      </div>
      <div><br>
      </div>
      <div>It returned 15 results so it's not a large result set by any
        means. The strings are like labels - there are &lt;20 things any
        one of the string fields can be.</div>
      <div><br>
      </div>
      <div>This query took a few minutes to run the first time.
        Re-running it again in the same session took &lt;1 second each
        time. When I restarted the session it took only 30 seconds, and
        again 1 second each subsequent time.</div>
      <div><br>
      </div>
      <div>What makes it run so slow? Is it that the catalog isn't fully
        in memory? If so, is there any way I can guarantee the catalog
        will be in memory given that my entire database doesn't fit in
        memory all at once?</div>
      <div><br>
      </div>
    </blockquote>
    I can't speak from experience, but using
    <a class="moz-txt-link-freetext" href="http://pypi.python.org/pypi/zc.zlibstorage">http://pypi.python.org/pypi/zc.zlibstorage</a> could help initial loads
    by speeding disk I/O and network transfer.<br>
    <br>
    To make sure the catalog is in memory you could keep it in a
    separate ZODB with different cache size.<br>
    <br>
    David<br>
  </body>
</html>