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

Get rid of the civicrm_group_contact_cache table

    Details

    • Versioning Impact:
      Patch (backwards-compatible bug fixes)
    • Documentation Required?:
      Developer Doc
    • Funding Source:
      Needs Funding

      Description

      I always wondered why we have the group_contact_cache table ... we could very well cache the smart group results in the group_contact table (with status = 'Smart') ... this way any queries on groups would just look at one table rather than have these Russian doll joins and ors!

      To list all contacts in a smart group:
      SELECT contact_id FROM civicrm_group_contact WHERE group_id = xxx AND status IN ('Added', 'Smart');

      Then, to refresh the smart group:
      DELETE FROM civicrm_group_contact WHERE group_id = xxx AND status = 'Smart'; INSERT IGNORE INTO civicrm_group_contact ... (results from smart group query)

      The INSERT IGNORE with a primary key on (group_id, contact_id) would take care of not adding smart group query results that already have an 'Added' or 'Removed' status.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              nganivet Nicolas Ganivet
            • Votes:
              4 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 2 days
                2d
                Remaining:
                Remaining Estimate - 2 days
                2d
                Logged:
                Time Spent - Not Specified
                Not Specified