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

Performance issues with many discounts

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Minor
    • Resolution: Done
    • Affects Version/s: 4.6
    • Fix Version/s: Unscheduled
    • Component/s: None
    • Labels:
      None
    • Documentation Required?:
      None
    • Funding Source:
      Needs Funding

      Description

      (Cross-posted from https://github.com/dlobo/org.civicrm.module.cividiscount/issues/154 – what's the best place for issues on this extension?)

      I have a site here with over 150 active discount codes, all based on either event ID or event type, none of which are set for Automatic Discounts.

      When loading any event registration page, the page takes around 30 seconds to load. Xdebug profiling output shows that this delay is caused by CRM_CiviDiscount_DiscountCalculator::checkDiscountsByEntity(), which performs a 'get event' API call on every one of those discount codes, in order to check whether any events meet the requirements of the discount code.

      Of course, CiviDiscount has to know if the event has an active discount code, so that it can display or hide the Discount Code field.

      So at this point I'm thinking that the data structure is the real problem here: currently, the storage mechanism associating a discount code with one or more events, or one or more event types, etc., is a single column delimited with CRM_Core_DAO::VALUE_SEPARATOR. This makes it hard to run a single query that can tell what discounts are associated with any given event, which is why the code is running one 'get event' API call for every discount code.

      Is it worth discussing changes to that schema for the sake of avoiding long page loads with large numbers of discount codes?

        Attachments

          Activity

            People

            • Assignee:
              allenshaw Allen Shaw
              Reporter:
              allenshaw Allen Shaw
            • Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: