← Docs

Postgres Extensions

Install these extensions to unlock all optimizations.

ExtensionWhat it enablesWithout itInstall
pg_stat_statementsInstant optimization on startupGL learns patterns from scratchEasy (usually already installed)
pg_trgmLIKE/ILIKE index optimizationWildcard queries work but remain slowerEasy (no restart)
Strongly recommendedpg_ivmZero-staleness matview refreshReads fall back to Postgres until matview refreshes (up to 60s)Moderate (restart + third-party package)

pg_stat_statements — Query History

Tracks execution statistics for all SQL statements — call count, total time, mean time, rows returned. Postgres maintains this data across restarts. Gold Lapel reads your hottest queries from pg_stat_statements on startup and immediately begins optimizing them. No warm-up period — matviews are created for your most impactful queries within the first refresh cycle.

Without it: Gold Lapel learns query patterns from scratch by observing traffic through the proxy. It takes min_pattern_count repetitions (default: 1) before Gold Lapel begins optimizing a query. For busy applications this happens in seconds; for low-traffic applications it may take minutes.

Install

-- 1. Add to postgresql.conf:
shared_preload_libraries = 'pg_stat_statements'
-- 2. Restart Postgres
-- 3. Create the extension:
CREATE EXTENSION IF NOT EXISTS pg_stat_statements;

Part of the Postgres contrib package. Available on all major providers. Many providers enable it by default — you may already have it.

pg_trgm — Trigram Indexes

Enables GIN trigram indexes for LIKE, ILIKE, and %pattern% queries. When Gold Lapel detects wildcard text searches hitting the same columns, it creates trigram indexes that make those searches orders of magnitude faster. A WHERE name ILIKE '%smith%' that previously required a sequential scan can use an index instead.

Without it: LIKE/ILIKE queries are proxied to Postgres as normal — they work, but without trigram indexes they fall back to sequential scans on every search.

Install

CREATE EXTENSION IF NOT EXISTS pg_trgm;

Part of the Postgres contrib package. Available on all major providers (RDS, Supabase, Neon, Cloud SQL). No restart required. Gold Lapel will auto-create it if permissions allow.

pg_ivm — Instant Matview Refresh

Maintains materialized views via triggers — every INSERT, UPDATE, or DELETE to a base table instantly updates the matview. Zero staleness. A write to orders immediately updates any matview that depends on orders. Reads always return fresh data. Strongly recommended to avoid full matview rebuilds on writes.

Without it: Matviews are refreshed on a polling cycle (default: every 60 seconds when the matview is active and its base tables have been written to). When Gold Lapel detects a write to a base table, it marks the matview stale and routes subsequent reads directly to Postgres — never serving stale cached data. The matview is refreshed on the next cycle and reads resume from it. The staleness window is configurable via refresh_interval_secs.

Install

-- 1. Install the pg_ivm package on your Postgres server
-- 2. Add to postgresql.conf:
shared_preload_libraries = 'pg_ivm'
-- 3. Restart Postgres
-- 4. Create the extension:
CREATE EXTENSION IF NOT EXISTS pg_ivm;

Third-party extension — not bundled with Postgres. Available on some managed providers. Check your provider's extension list.

Checking Your Extensions

To see which extensions are installed:

SELECT extname FROM pg_extension
WHERE extname IN ('pg_trgm', 'pg_ivm', 'pg_stat_statements');

On startup, Gold Lapel checks for all three and logs the result:

All installed
extensions: all installed (pg_trgm, pg_ivm, pg_stat_statements)
Some missing
extensions: install missing extensions for optimal performance installed="pg_trgm" missing="pg_ivm, pg_stat_statements"

Gold Lapel also attempts to auto-create extensions (CREATE EXTENSION IF NOT EXISTS) if it has sufficient permissions. If it cannot, it logs the manual install command.