Building a local business directory that stays fast past a few hundred thousand listings requires more than a basic SELECT * FROM listings WHERE city = ? query. Whether you are indexing neighborhood contractors, regional educators, or service providers on platforms like local business and service listing directories, users expect instant category filtering, clean URL slugs, and zero duplicate records.

When refactoring directory backends for high-read traffic, four database modeling choices make the biggest difference in query speed and data hygiene.

1. Model Categories as a Materialized Path or ltree

Hierarchical categories (Education > Online Tutoring > Exam Prep) get messy quickly if you rely on recursive CTEs for every page load.

  • Use PostgreSQL's ltree extension (education.online_tutoring.exam_prep) paired with a GiST index so querying an entire parent branch takes a single index scan.
  • Store canonical category slugs separately from display labels so renaming a category in the UI never breaks indexed URLs.

2. Combine Composite B-Tree Indexes With Full-Text Search

Most directory traffic hits compound routes combining location and category (/{region}/{category}), followed by keyword searches.

  • Create a composite index on (status, country_code, region_slug, category_path) so active regional pages resolve without sorting in memory.
  • Maintain a generated tsvector column weighting business titles (A), service tags (B), and descriptions (C) backed by a GIN index for instant keyword lookups.

3. Enforce Deterministic Deduplication at Ingestion

Directory data degrades fast when slight variations ("Acme Tutoring LLC" vs "Acme Tutoring") create split profiles.

  • Normalize business names, domains, and phone numbers into a deterministic fingerprint hash before insertion.
  • Route near-matches into a moderation queue using trigram similarity (pg_trgm) rather than silently creating duplicate slugs.

4. Cache Aggregate Facet Counts Asynchronously

Running live COUNT(*) queries across dozens of sidebar filters on every request bottlenecks your database under bot and crawler traffic. Precompute facet counts into a lightweight summary table updated via background workers whenever listings change state.

How do you handle hierarchical taxonomy filtering and deduplication in large catalog or directory apps? Share your setup in the comments.