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

When searching for soft credits from contribution search an unfiltered temp table is created

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 4.7.4
    • Fix Version/s: Unscheduled
    • Component/s: None
    • Labels:
      None
    • Versioning Impact:
      Patch (backwards-compatible bug fixes)
    • Documentation Required?:
      None
    • Funding Source:
      Needs Funding

      Description

      The code to create a table to query for temp tables creates a temp table of all contributions & all soft credits to query it. Given that contribution tables of several hundred megabytes are common and a number of orgs have them over a GB this is awfully inefficient.

      Applying the search criteria to the temp table creation would keep it manageable - here is the query

      $tempQuery = "
      CREATE TEMPORARY TABLE IF NOT EXISTS contribution_search_scredit_combined AS
      SELECT con.id as id, con.contact_id, cso.id as filter_id, NULL as scredit_id
      FROM civicrm_contribution con
      LEFT JOIN civicrm_contribution_soft cso ON con.id = cso.contribution_id
      GROUP BY id, contact_id, scredit_id
      UNION ALL
      SELECT scredit.contribution_id as id, scredit.contact_id, scredit.id as filter_id, scredit.id as scredit_id
      FROM civicrm_contribution_soft as scredit";

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              eileen Eileen McNaughton
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: