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 |
|---|---|---|
| .. | ||
| ability.go | Loading commit data... | |
| channel.go | Loading commit data... | |
| channel_cache.go | Loading commit data... | |
| channel_satisfy.go | Loading commit data... | |
| checkin.go | Loading commit data... | |
| custom_oauth_provider.go | Loading commit data... | |
| db_time.go | Loading commit data... | |
| errors.go | Loading commit data... | |
| log.go | Loading commit data... | |
| main.go | Loading commit data... | |
| midjourney.go | Loading commit data... | |
| missing_models.go | Loading commit data... | |
| model_extra.go | Loading commit data... | |
| model_meta.go | Loading commit data... | |
| model_owner_test.go | Loading commit data... | |
| option.go | Loading commit data... | |
| passkey.go | Loading commit data... | |
| payment_method_guard_test.go | Loading commit data... | |
| perf_metric.go | Loading commit data... | |
| prefill_group.go | Loading commit data... | |
| pricing.go | Loading commit data... | |
| pricing_default.go | Loading commit data... | |
| pricing_refresh.go | Loading commit data... | |
| redemption.go | Loading commit data... | |
| setup.go | Loading commit data... | |
| subscription.go | Loading commit data... | |
| task.go | Loading commit data... | |
| task_cas_test.go | Loading commit data... | |
| token.go | Loading commit data... | |
| token_cache.go | Loading commit data... | |
| topup.go | Loading commit data... | |
| twofa.go | Loading commit data... | |
| usedata.go | Loading commit data... | |
| usedata_rankings.go | Loading commit data... | |
| user.go | Loading commit data... | |
| user_cache.go | Loading commit data... | |
| user_oauth_binding.go | Loading commit data... | |
| utils.go | Loading commit data... | |
| vendor_meta.go | Loading commit data... |