Indexer
Database indexes improve query performance for large collections.
What are Indexes?
Indexes help the database find records faster, similar to an index in a book. Without indexes, the database must scan every record to find matches.
Creating an Index
- Navigate to your collection's Indexer tab
- Click + Add Another Indexer
- Configure the index:
| Field | Description |
|---|---|
| Fields | Select one or more fields to index |
| Name | Auto-generated index name (e.g., users_email_idx) |
| Unique | Enforce unique values across selected fields |
- Click Save to create the index
When to Use Indexes
Add indexes for:
- Fields frequently used in search/filter
- Fields used in WHERE clauses
- Foreign key fields
- Fields that need unique constraints
Avoid indexes for:
- Fields rarely queried
- Small collections (< 1000 records)
- Fields with low cardinality (few unique values)
Compound Indexes
Select multiple fields to create a compound index. Useful when you often query by multiple fields together.
Example: Index on (customer_id, order_date) for efficient customer order lookups.
Unique Indexes
Check Unique to prevent duplicate values. This enforces data integrity at the database level.
Use cases:
- Email addresses
- Usernames
- SKU codes