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,
What I tried:
- attempted to modify the query to leverage the existing
preferredEventProductIndex
onproductSummaryEventStatus
- This was a composite index
KEY preferredEventProductIndex (eventId, eventPreferred)
on theproductSummaryEventStatus
table
- This was a composite index
Improvement of query:
- You can see the improvement in the
filtered
column, the query did not have to scan as much of the table. - 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 theevent_pointtime_index
, but after adding the indexeventPreferredIndex
it choses to bypass the index onevent.eventTime
(the composite indexevent_pointtime_index
).