Closed
Description
- Gitea version (or commit ref): 1.14.5 / 1.14.6
- Git version: 2.30.2
- Operating system: Fedora CoreOS, running gitea officical container on podman
- Database (use
[x]
):- PostgreSQL
- MySQL (mariadb)
- MSSQL
- SQLite
- Can you reproduce the bug at https://try.gitea.io:
- Yes (provide example URL)
- No
Description
Super slow loading of the Dashboard where the list of actions is displayed.
There are about 300k action entries in the database for the last year.
Most users have around 10k up to 30k actions if selected on their user_id.
When doing an EXPLAIN
on
SELECT `id`, `user_id`, `op_type`, `act_user_id`, `repo_id`, `comment_id`, `is_deleted`, `ref_name`, `is_private`, `content`, `created_unix`
FROM `action`
WHERE user_id=1 AND is_deleted=0
ORDER BY `id` DESC LIMIT 20;
there will be two indexes merged (on disk) IDX_action_is_deleted
and IDX_action_user_id
it seems the is_deleted
one is taken first and so the query takes around 5 seconds
there are three ways of temporarily fixing the issue
- creating a composite index on both fields
- adding a
FORCE INDEX(IDX_action_user_id)
to the query changes the order of the indexes used - (currently the best results) just dropping the
IDX_action_is_deleted
index
as a result the speed for the query goes down to sub milliseconds
maybe just removing the index from the deleted field in the action model would be the easiest one?