Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid using the incorrect index with heavy scheduled event count #7901

Open
wants to merge 1 commit into
base: staging
from

Conversation

@heathdutton
Copy link
Member

heathdutton commented Oct 1, 2019

Please be sure you are submitting this against the staging branch.

Q A
Bug fix? Y
New feature?
Automated tests included?
Related user documentation PR URL
Related developer documentation PR URL
Issues addressed (#s or URLs)
BC breaks? N
Deprecations? N

Description:

At high volume, when there are a few hundred thousand campaign events scheduled to occur (say you get a bit behind) MySQL will stop using the campaign_events_scheduled index and instead try to use campaign_actions for scheduled campaign event triggers (particularly 5.6+).

This is bad, because it takes a query that may take 7 seconds, and causes it to take more like 900 seconds.

We don't like to force indexes w/ DBAL, but luckily a one-character change to the query will result in more efficiency and no accidental index use (by building on the first join).

Changes this:
Screen Shot 2019-10-01 at 12 53 35 AM

To this:
Screen Shot 2019-10-01 at 12 53 47 AM

Steps to test this PR:

  1. Unit tests will suffice.
@heathdutton heathdutton changed the title Avoid using the incorrect index. Avoid using the incorrect index with heavy scheduled event count Oct 1, 2019
@heathdutton

This comment has been minimized.

Copy link
Member Author

heathdutton commented Oct 6, 2019

We had to implement this in production as an emergency patch. But it has been running fine for the past 2 weeks with no issues... So at least it's been thoroughly tested :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.