Skip to content

Resolve "Count query not using indexes"

fixes #25 (closed)

This MR:

  • adds index on productSummaryEventStatus.eventPreferred for event count query
  • makes the ORDER BY section of the getWhere optional,
    • this fixes a problem that I noticed in MySQL v8.4 where the order by column must be in the select list image

What I tried:

  • attempted to modify the query to leverage the existing preferredEventProductIndex on productSummaryEventStatus
    • This was a composite index KEY preferredEventProductIndex (eventId, eventPreferred) on the productSummaryEventStatus table

Improvement of query:

  • You can see the improvement in the filtered column, the query did not have to scan as much of the table. image
  • However there is still the where clause for e.eventTime >= '1679173202000'. This appears to be ignoring the index that exists for it. If you look at the previous query it uses the event_pointtime_index, but after adding the index eventPreferredIndex it choses to bypass the index on event.eventTime(the composite index event_pointtime_index).
    • Even when I create an single purpose index for event.eventTime (seen below as event_eventtime_index) it still ignores the index. image

Merge request reports

Loading