Default indexes
These fields are already indexed and optimized:Use Typesense for large-scale queries
For complex searches, filtering across millions of records, or when you need sub-millisecond response times, use Blnk’s Typesense integration instead of database queries. Typesense is optimized for:- Full-text search across any field
- Faceted filtering with instant results
- Sorting large datasets without custom indexes
See Search via Typesense docs for more.
Adding custom indexes
If you’re not using Typesense and frequently sort or filter by a specific field at scale, add an index.1
Create single column indexes
Create indexes for frequently filtered or sorted fields:
2
Create composite indexes
For queries that filter and sort on multiple fields, composite indexes are more efficient:
3
Create metadata indexes
If you frequently filter on a specific metadata key, index that key directly:
Debugging slow queries
UseEXPLAIN ANALYZE to see how Postgres executes a query:
Seq Scanon large tables: strong signal you need an index- High actual time values: indicates slow query execution
- Large row counts being filtered down late: suggests missing indexes
Example Output
status would improve performance.
Best practices
-
Monitor query performance: Use
EXPLAIN ANALYZEregularly to identify slow queries. - Index strategically: Only add indexes for fields you filter or sort on frequently. Too many indexes can slow down writes.
- Use composite indexes: When filtering and sorting on multiple fields together, create composite indexes.
- Consider Typesense: For complex queries or very large datasets, Typesense often provides better performance than database indexes.
- Test in production-like environments: Index performance can vary based on data distribution and query patterns.