The idx_created_at_id composite index on the logs table was defined as (id, created_at) because the GORM `priority` values on Id and CreatedAt were swapped. Since `id` is the auto-increment primary key, a secondary composite index leading with `id` is redundant with the PK and cannot accelerate `created_at` range scans (a range column must sit at the index prefix). This defeats the common log-listing queries (`WHERE created_at BETWEEN ? AND ? ORDER BY id DESC LIMIT n` in GetAllLogs/GetUserLogs) that the index name implies it should serve — the optimizer falls back to scanning the primary key, degrading to near full-table scans on large logs tables. Swap the priorities so the column order becomes (created_at, id), matching the index name and its intended purpose. idx_user_id_id and idx_created_at_type are unaffected. Note: GORM AutoMigrate does not change the column order of an already-existing index with the same name, so existing deployments must rebuild the index manually (see PR description for per-database DDL). Co-authored-by: wuyupeng <wuyupeng@floatmiracle.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
| Name |
Last commit
|
Last Update |
|---|---|---|
| .agents/skills | Loading commit data... | |
| .github | Loading commit data... | |
| bin | Loading commit data... | |
| common | Loading commit data... | |
| constant | Loading commit data... | |
| controller | Loading commit data... | |
| docs | Loading commit data... | |
| dto | Loading commit data... | |
| electron | Loading commit data... | |
| i18n | Loading commit data... | |
| logger | Loading commit data... | |
| middleware | Loading commit data... | |
| model | Loading commit data... | |
| oauth | Loading commit data... | |
| pkg | Loading commit data... | |
| relay | Loading commit data... | |
| router | Loading commit data... | |
| service | Loading commit data... | |
| setting | Loading commit data... | |
| types | Loading commit data... | |
| web | Loading commit data... | |
| .dockerignore | Loading commit data... | |
| .env.example | Loading commit data... | |
| .gitattributes | Loading commit data... | |
| .gitignore | Loading commit data... | |
| AGENTS.md | Loading commit data... | |
| CLAUDE.md | Loading commit data... | |
| Dockerfile | Loading commit data... | |
| Dockerfile.dev | Loading commit data... | |
| LICENSE | Loading commit data... | |
| NOTICE | Loading commit data... | |
| README.en.md | Loading commit data... | |
| README.fr.md | Loading commit data... | |
| README.ja.md | Loading commit data... | |
| README.md | Loading commit data... | |
| README.zh_CN.md | Loading commit data... | |
| README.zh_TW.md | Loading commit data... | |
| THIRD-PARTY-LICENSES.md | Loading commit data... | |
| VERSION | Loading commit data... | |
| docker-compose.dev.yml | Loading commit data... | |
| docker-compose.yml | Loading commit data... | |
| go.mod | Loading commit data... | |
| go.sum | Loading commit data... | |
| main.go | Loading commit data... | |
| makefile | Loading commit data... | |
| new-api.service | Loading commit data... |