Skip to content

Conversation

@zachjesus
Copy link

@zachjesus zachjesus commented Jan 28, 2026

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.
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.

1 participant