Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-12565 Search Optimizations in 4.4
  3. CRM-12639

Eliminate left joins with option value / group, state, country, county tables in search queries

    Details

    • Type: Sub-task
    • Status: Done/Fixed
    • Priority: Major
    • Resolution: Fixed/Completed
    • Affects Version/s: 4.4.0
    • Fix Version/s: 4.4.2
    • Component/s: CiviCRM Search
    • Labels:
      None

      Description

      On large data sets and/or export queries where we export a large set of contacts, we use a fair number of left joins. Basically we retrieve:

      gender
      prefix
      suffix
      state
      country
      world region

      via a left join to the above tables. The above tables are pseudo-constants and are cached in either memcache or mysql query cache. So if we just retrieve the ids, we can then use an array lookup to retrieve the value.

      On tests against a sample NYSS db and the EFF db, we've seen a 8-12x query improvement on the entire contact set.

        Attachments

        1. contact.sql
          7 kB
          Donald A. Lobo
        2. contactOpt.sql
          6 kB
          Donald A. Lobo
        3. contactOpt1.sql
          5 kB
          Donald A. Lobo

          Issue Links

            Activity

              People

              • Assignee:
                lcdweb Brian Shaughnessy
                Reporter:
                lobo Donald A. Lobo
              • Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Due:
                  Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 1 week, 5 hours, 6 minutes
                  1w 5h 6m