Files
open-webui/backend/open_webui/utils
Classic298 16c2a9eda4 fix: index the chat queries that make large SQLite instances unusable (#27663)
The timer scheduler polls once a second and cancels on every message send and chat open, the sidebar lists chats ordered by `updated_at`, and the folder badges count unread chats per folder. None of those could be served by an index, so each call read most of the `chat` table, and because `meta` sits after the chat payload column SQLite had to walk every row's overflow pages to get there. On a large history that stalls the sidebar, every chat switch and every send, and the idle poll alone burns about a quarter of a CPU core.

Timers now keep their due time in a dedicated `chat.timer_at` column behind a partial index, and the chat list, unread and unfinished-reply queries each get an index matching their filter and ordering. Existing pending timers are backfilled from their meta by the migration. Dropping the `internal` and `type` checks also makes a forked timer chat inert, where a fork used to copy `meta` verbatim and become a second claim target that could fire a duplicate timer.

Measured on SQLite, same rows returned:

| query | before | after |
|---|---|---|
| idle timer poll (2000 chats, 0.43 GB) | 170 ms | 0.04 ms |
| cancel on send and chat open (4000 chats, 377 MB) | 200 ms | 0.04 ms |
| sidebar chat list (15000 chats, 1.26 GB) | 157 ms | 1.8 ms |
| folder unread badges (15000 chats, 1.4 GB) | 54 ms | 0.2 ms |

PostgreSQL 17 serves all of them as index-only scans with no sort node. Exercised through fresh install, upgrade with seeded data, downgrade and re-upgrade on SQLite and PostgreSQL 17.

Fixes #27622
2026-08-23 16:11:54 -05:00
..
2026-06-29 11:56:00 -05:00
2026-07-31 17:41:14 -04:00
2026-08-13 21:02:17 -06:00
2026-08-13 16:42:10 -06:00
2026-07-31 17:30:47 -04:00
2026-03-17 17:58:01 -05:00
2026-07-23 02:54:56 -04:00
2026-07-26 21:12:14 -04:00
2026-07-31 17:41:14 -04:00
2026-07-31 17:41:14 -04:00
2026-08-23 13:36:53 -04:00
2026-07-23 21:29:33 -04:00
2026-07-27 00:12:47 -04:00
2026-08-10 19:28:21 -06:00
2026-08-23 02:34:08 -04:00
2026-07-26 23:09:22 -04:00
2026-08-13 00:07:31 -06:00
2026-07-27 19:39:36 -04:00
2026-08-16 22:56:19 -07:00
2026-08-17 00:57:57 -07:00
2026-03-17 17:58:01 -05:00
2026-07-27 04:17:00 -04:00
2026-08-10 20:13:03 -06:00
2026-06-19 00:16:06 +02:00
2026-08-19 22:48:32 -07:00
2026-08-16 22:52:24 -07:00
2026-08-23 15:14:43 -04:00
2026-07-27 19:39:36 -04:00
2026-07-31 17:41:14 -04:00