Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request Type
Relevant Issues
No corresponding issue identified. I understand CONTRIBUTING.md requires a corresponding issue before merge. This is a draft proposal for feedback on whether this read/write tradeoff fits AnythingLLM; it is not merge-ready.
Description
With retained chat history and a per-user daily message cap, counting workspace_chats by user and creation cutoff scans the chat table. This adds one Prisma index and its SQLite migration:
(user_id, workspaceId, thread_id, api_session_id, include, id, createdAt)The user prefix lets the quota count scan covering index entries for that user instead of all chat payloads. Time is evaluated within that user's entries; this is not a timestamp range seek. For history queries constraining the full user/workspace/thread/API/include partition, the index supplies
id DESC LIMIT 20without a temporary sort. No query predicates or application JavaScript change.This branch contains only the schema declaration and migration. Reproducible checks, all raw results and explanation are preserved in the fork.
Measurements and tradeoffs
Baseline: upstream
049d721f900f394c1415ebd7db69a552194c9736. Twelve synthetic matched SQLite pairs on one Windows host, three pairs per size/cache group, 31 measured repetitions after three warm-ups for reads/sequences; no discarded pairs.At 100k–1M rows across 8 MiB and 512 MiB cache settings:
This has meaningful costs:
These results support a bounded query improvement, not a universal application improvement. Bulk-write overhead, alternate query shapes, production concurrency and migration locking need further evaluation before adoption. There is no measured hosting/LLM bill saving or accepted-user-outcome cost claim.
Validation
git diff --checkpassed. The MIT license and upstream attribution remain unchanged.Developer Validations
yarn lintfrom the root of the repo & committed changes