hermes-agent/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/developer-guide
spfcraze 8f91e249e4 perf(state): add messages(session_id, id) index for window/ordering queries
Every ORDER BY id query on the messages table sorted or scanned the
whole session: get_messages_around's window seek, latest_message_row_id
(LIMIT 1), and get_messages' full-load ordering all paid O(session
history) per call — hot mid-turn via session_search and reactions.
messages.id is an original column (INTEGER PRIMARY KEY AUTOINCREMENT),
so the index lives in SCHEMA_SQL next to idx_messages_session — no
legacy-column migration hazard (the kanban lesson from #28776 does not
apply).

Measured (real schema, one 20k-message session, median of 30):
get_messages_around 7.08 -> 0.22 ms (32x), latest_message_row_id
3.37 -> 0.011 ms (307x), get_messages full load 111.6 -> 98.6 ms
(1.13x — remaining cost is row deserialization, not the sort).
Window results byte-identical at probe points across the session.

Tests: VM-step pin (get_messages_around bounded work, calibrated
~12 vs ~855 handler calls, threshold 300 — fails without the index)
and window parity with/without the index. No EXPLAIN/plan text
(behavior contracts, AGENTS.md).
2026-08-02 21:16:17 +05:30
..
plugins docs: browser provider plugin guide + complete the plugin routing map (#59817) 2026-07-06 12:43:03 -07:00
acp-internals.md rip out brew + pip/PyPI wheel support (#68217) 2026-07-22 16:51:01 -04:00
adding-platform-adapters.md docs: repoint remaining stale gateway/platforms adapter refs to plugins/platforms 2026-06-21 19:59:50 -07:00
adding-providers.md docs: purge stale xdist/_enforce_test_timeout test-runner references repo-wide 2026-07-29 23:16:18 -07:00
adding-tools.md docs: Plugins subcategory under Extending + secret-source plugin guide + 1Password sidebar fix (#59613) 2026-07-06 12:11:31 -07:00
agent-loop.md feat: raise default tool-calling iteration limit from 90 to 500 2026-07-26 12:54:45 -07:00
architecture.md Revert "remove Vercel AI Gateway and Vercel Sandbox (#33067)" 2026-07-29 19:48:37 -07:00
browser-supervisor.md
context-compression-and-caching.md
context-engine-plugin.md
contributing.md docs(i18n): align translated CONTRIBUTING files with pyproject Python range (3.11-3.13) 2026-07-08 07:09:23 -07:00
creating-skills.md
cron-internals.md docs(cron): document explicit per-channel delivery targets for all platforms (#54630) 2026-06-29 15:23:16 +10:00
extending-the-cli.md
gateway-internals.md docs: sync overnight sweep with registry, gateway, curator, cron 2026-07-29 09:45:11 -07:00
image-gen-provider-plugin.md docs: Plugins subcategory under Extending + secret-source plugin guide + 1Password sidebar fix (#59613) 2026-07-06 12:11:31 -07:00
memory-provider-plugin.md
model-provider-plugin.md docs: Plugins subcategory under Extending + secret-source plugin guide + 1Password sidebar fix (#59613) 2026-07-06 12:11:31 -07:00
plugin-llm-access.md
programmatic-integration.md
prompt-assembly.md feat(prompt): make context-file truncation limit configurable 2026-06-16 11:28:35 -07:00
provider-runtime.md Revert "remove Vercel AI Gateway and Vercel Sandbox (#33067)" 2026-07-29 19:48:37 -07:00
session-storage.md perf(state): add messages(session_id, id) index for window/ordering queries 2026-08-02 21:16:17 +05:30
tools-runtime.md Revert "remove Vercel AI Gateway and Vercel Sandbox (#33067)" 2026-07-29 19:48:37 -07:00
trajectory-format.md
video-gen-provider-plugin.md
web-search-provider-plugin.md docs: Plugins subcategory under Extending + secret-source plugin guide + 1Password sidebar fix (#59613) 2026-07-06 12:11:31 -07:00