Skip to content

Added proposed code for materialized view. #11

Open
zachjesus wants to merge 1 commit into
gutenbergtools:mainfrom
zachjesus:main
Open

Added proposed code for materialized view. #11
zachjesus wants to merge 1 commit into
gutenbergtools:mainfrom
zachjesus:main

Conversation

@zachjesus

@zachjesus zachjesus commented Jan 28, 2026

Copy link
Copy Markdown

Overview

This PR introduces a denormalized cache table to optimize book metadata queries for search and filtering operations.

Implementation Details

Important: The pg_trgm extension setup code must run before the migration. It will fail if executed afterward.

What This Does

Creates a pre-joined cache table containing essential book metadata fields needed for search/filter/display operations. This eliminates the need for runtime joins when querying book data.

Benefits

  • Significantly faster search/filter queries by eliminating join overhead (up to 90% in some cases)
  • Trades ~600MB storage for reduced processing load on DB server
  • Read-only table (SQL injection safe by default)

Storage Impact

  • Current: ~600MB
  • Projected (10 years @ 400 books/month): ~1.2GB

…of the file is intended to fix the pg_trgm install before updating. It will not work after.
@cpeel

cpeel commented Jun 9, 2026

Copy link
Copy Markdown
Member

Let me get a 15_* cleanup script in here that will fix the extension. After we have that working and merged we can rename your script 16_* and it can assume the extension is installed correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants