Ignore:
Timestamp:
4 Nov 2019, 10:15:44 (5 years ago)
Author:
uli
Message:

Bad workaround to cope with overcrowded catalogs.

Zope does not cope well with catalogs of more than 500.000 elements.
Reindexing the catalog then means to put all objects into memory before
saving them - this can blow everything.

We therefore use a dirty hack to replace the updateIndex method of
a catalog with a more careful function, that, however, should not be
run in production mode. No new items should be added during the run.

In the long run, we certainly need something more sustainable.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/utils/helpers.py

    r15739 r15748  
    2727import shutil
    2828import tempfile
     29import transaction
    2930import grok
    3031from cStringIO import StringIO
     
    956957    uids = get_catalog_docids(cat)
    957958    print("Found %s entries..." % len(uids))
    958     for docid in uids:
     959    for n, docid in enumerate(uids):
    959960        ob = uidutil.getObject(docid)
    960961        cat.index_doc(docid, ob)
     962        # indexes can become huge. commit changes every 5000th round to
     963        # keep the memory footprint of catalogs `updateIndex` manageable
     964        if not n % 5000:
     965            transaction.commit()
    961966    d2 = datetime.datetime.now()
    962967    print("Finished. %s" % (d2 - d1))
Note: See TracChangeset for help on using the changeset viewer.