Precompute content_chars to drop per-render body scans

The N-min-read chip derived reading time via LENGTH(content) over the
full article-body TEXT column on every listing render. LENGTH can't use
an index, so SQLite read each row's whole body per request on the hottest
path. Cache the character count in a content_chars column filled at insert
time (backfilled for existing rows), and point StoryContentLengths at it.
This commit is contained in:
prosolis
2026-07-07 22:41:41 -07:00
parent 8f9fcc45f3
commit 74aa578a2d
3 changed files with 30 additions and 7 deletions

View File

@@ -7,6 +7,7 @@ CREATE TABLE IF NOT EXISTS stories (
headline TEXT NOT NULL,
lede TEXT,
content TEXT,
content_chars INTEGER NOT NULL DEFAULT 0,
image_url TEXT,
article_url TEXT NOT NULL,
url_canonical TEXT,