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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user