The Search-as-You-Type Problem Type "bts" into a search box — a user in Korea probably wants BTS music videos. Type "けん" and they want results for any Japanese title containing those kana. Generic substring matching is too slow at scale; full-text search is too rigid for autocomplete. PostgreSQL's pg_trgm extension sits in the sweet spot. TopVideoHub serves video search across 9 Asia-Pacific regions, where multi-script autocomplete is non-trivial. Here's how we built it. What Is pg_trgm? A trigram is a group of three consecutive characters. The word hello decomposes to h , he , hel , ell , llo , lo . PostgreSQL can index these trigrams and use them to compute string similarity in microseconds.…