Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-7675

Export of search results is O(n^2), should be O(n)

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Minor
    • Resolution: Fixed/Completed
    • Affects Version/s: 3.3.5
    • Fix Version/s: 3.4.alpha
    • Component/s: CiviCRM Search
    • Labels:

      Description

      I was doing a search over all our contacts (about 40K) yesterday to produce a name/address CSV file for a mass mailing and was wondering why this export was taking almost half an hour (so only producing about 20 CSV rows per second).

      Looking at the MySQL Processlist it turned out that the export is performed pagination, using LIMIT to get 100 rows at a time ... so instead of running the search query just once to produce the CSV it was actually executed about 400 times, with each query taking a little longer and the final one taking exactly the same amount of time alone that the 'primitive' just-give-me-all approach would have needed for its single query.

      The results produced are ok, but this is causing major acceptance problems with the users of our instance.

      Solution: fire the search query only once when doing an export, do not use LIMIT to redo it again and again with different parts of the result set getting filtered out.

      In my use case this would probably bring down export time from about half an hour to just a few seconds ...

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                lobo Donald A. Lobo
                Reporter:
                hholzgra Hartmut Holzgraefe
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: