← back to AsSeenInMovies
asseeninmovies: /search perf — gate ILIKE search to poster/headshot-having rows only (the visually-rich subset users actually want). Was full-scanning 290k movies + 61k people on every keystroke (5s+ timeout); now lands on the partial idx_asim_movies_has_poster index. /search?q=hotel 5s → 877ms cold, 10-14ms warm.
19107943b07c80d9cd40fad3dc3943ff7ecc1de1 · 2026-05-12 19:02:47 -0700 · SteveStudio2
Files touched
Diff
commit 19107943b07c80d9cd40fad3dc3943ff7ecc1de1
Author: SteveStudio2 <stevestudio2@SteveStacStudio.lan>
Date: Tue May 12 19:02:47 2026 -0700
asseeninmovies: /search perf — gate ILIKE search to poster/headshot-having rows only (the visually-rich subset users actually want). Was full-scanning 290k movies + 61k people on every keystroke (5s+ timeout); now lands on the partial idx_asim_movies_has_poster index. /search?q=hotel 5s → 877ms cold, 10-14ms warm.
---
server.js | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/server.js b/server.js
index 421ef36..9a8239b 100644
--- a/server.js
+++ b/server.js
@@ -84,9 +84,15 @@ app.get('/search', async (req, res) => {
if (q.length >= 2) {
const like = '%' + q + '%';
try {
+ // Limit search to the visually-rich subset (with posters / headshots).
+ // The full asim_movies table is 290k rows of mostly stub data; ILIKE
+ // against the curated ~1.3k poster-having movies is fast against the
+ // partial idx_asim_movies_has_poster index. Users searching for a
+ // movie expect to see it WITH a poster; stub-only results aren't
+ // shippable until enrichment fills in their images anyway.
const [m, p] = await Promise.all([
- pool.query(`SELECT id, title, release_year, poster_url FROM asim_movies WHERE title ILIKE $1 ORDER BY (poster_url IS NOT NULL) DESC, release_year DESC NULLS LAST LIMIT 24`, [like]),
- pool.query(`SELECT id, full_name, headshot_url, primary_profession FROM asim_people WHERE full_name ILIKE $1 ORDER BY (headshot_url IS NOT NULL) DESC, full_name LIMIT 24`, [like]),
+ pool.query(`SELECT id, title, release_year, poster_url FROM asim_movies WHERE poster_url IS NOT NULL AND title ILIKE $1 ORDER BY release_year DESC NULLS LAST, id DESC LIMIT 24`, [like]),
+ pool.query(`SELECT id, full_name, headshot_url, primary_profession FROM asim_people WHERE headshot_url IS NOT NULL AND full_name ILIKE $1 ORDER BY full_name LIMIT 24`, [like]),
]);
movies = m.rows; people = p.rows;
} catch (e) { /* fall through to empty */ }
← 880a1dd asseeninmovies: htmlShell — auto-emit baseline meta descript
·
back to AsSeenInMovies
·
asseeninmovies: /api/health perf — pull counts from _homeCac 592a2e7 →