superset
superset copied to clipboard
missing a `dttm` index on `logs` table results in full table scan when visiting Activity Log
Bug description
- For the activity log page, the request is
GET /api/v1/log/ordered bydttm desc(ORDER BY dttm DESC LIMIT 25) - The only index on
logsis(user_id, dttm), from migrationcdcf3d64daf4 - Therefore, visiting the activity page causes full table scan. In production environments, even with log pruning enabled, activity log can easily reach a few million records, meaning a heavy load for the database.
I suggest adding a migration to index dttm for logs.
I am using superset version 6.1 but have already checked the source code for master/latest-dev, and the index is not there. nodejs/python/chrome versions are not relevant to the database issue in this case.
Screenshots/recordings
No response
Superset version
6.1.0
Python version
3.11
Node version
16
Browser
Chrome
Additional context
No response
Checklist
- [x] I have searched Superset docs and Slack and didn't find a solution to my problem.
- [x] I have searched the GitHub issue tracker and didn't find a similar bug report.
- [x] I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.
Same cause as #46145. I measured both open PRs (#46046 and #46151) against the Activity page query there: on a 3M-row logs table either one takes it from a 455 ms parallel seq scan to a 0.2 ms index scan. Numbers and setup are in #46145.