Indexes
Indexes are database structures that improve query performance by allowing the database to find and retrieve data faster. Think of an index like a book's index-instead of scanning every page to find a topic, you can jump directly to the relevant pages.
Why Use Indexes?
Without indexes, the database must scan every row in your table to find matching records, which becomes increasingly slow as your table grows. Indexes provide several key benefits:
- Faster Query Performance: Retrieve data in milliseconds, especially for large tables with millions of rows.
- Efficient Filtering: Speed up searches on columns you frequently filter by in your workflows or in Tables filters.
- Improved Sorting: Accelerate queries that sort data by specific columns.
- Better User Experience: Reduce loading times for table views and workflow executions.
Create indexes on columns that you frequently use in:
- Tables activity filters
- Tables UI searches
- Sorting operations
- Join conditions with other tables
Creating an Index
You can create indexes on single columns or multiple columns (composite indexes) to optimize different types of queries.
Single Column Index
To create an index on a single column:
-
Open your table and navigate to the Indexes tab
-
Click Add Index
-
Select the column you want to index and choose an appropriate index type
-
Click Create Index
Composite Index
You can create indexes that span multiple columns too. This is useful when you frequently filter or sort by multiple columns together.
-
To create a composite index, select columns in the order you want them indexed
-
Choose an appropriate index type based on data type and index compatibility for the composite index
-
Click Create Index
The order of columns in a composite index is crucial for performance. The index is most effective when your queries filter or sort by columns in the same order as defined in the index.
Example: If you create an index on [status, created_at, priority], it will efficiently handle filters like:
status = 'active'status = 'active' AND created_at > '2024-01-01'status = 'active' AND created_at > '2024-01-01' AND priority = 'high'
But it will be less effective for:
created_at > '2024-01-01'(doesn't use first column)priority = 'high'(doesn't use first columns)
Index Methods
Fynd Boltic Database supports multiple indexing algorithms, each optimized for different data patterns and query types. Here are the available index methods:
B-Tree
B-Tree is the most versatile and commonly used index type. It efficiently handles queries with equality comparisons (=), range comparisons (<, >, <=, >=, BETWEEN), and sorting (ORDER BY).
-
Best for: Equality and range queries, sorting operations
-
Use when: You need general-purpose indexing for most data types and query patterns.
Hash
Hash indexes are optimized for simple equality lookups but cannot handle range queries or sorting. They can be slightly faster than B-Tree for pure equality checks on large datasets.
-
Best for: Exact equality matches only
-
Use when: You only perform exact match queries (e.g., looking up records by ID).
-
Limitation: Hash indexes do not support multi-column indexes.
GIN (Generalized Inverted Index)
GIN indexes are designed for columns containing multiple values, such as dropdown multi-select columns.
-
Best for: Multi-valued data like dropdowns and full-text search
-
Use when: You have dropdown columns with multi-select enabled.
SP-GiST (Space-Partitioned Generalized Search Tree)
SP-GiST is useful for specialized searches, particularly prefix matching on text columns (e.g., LIKE 'abc%' queries).
-
Best for: Non-balanced data structures, prefix searches
-
Use when: You frequently search by text prefixes or work with hierarchical data.
-
Limitation: SP-GiST does not support multi-column indexes.
BRIN (Block Range Index)
BRIN indexes are extremely compact and work well on huge tables where data is physically sorted or clustered (e.g., timeseries data stored in tables).
-
Best for: Very large tables with naturally sorted data
-
Use when: You have large tables with sequential data like date-time or IDs, and you perform range queries.
Data Type and Index Compatibility
Not all index methods work with all data types. Here's a compatibility matrix to help you choose the right index type:
| Data Type | B-Tree | Hash | SP-GiST | GIN | BRIN |
|---|---|---|---|---|---|
| Text | ✓ | ✓ | ✓ | ✗ | ✓ |
| Long Text | ✓ | ✓ | ✓ | ✗ | ✓ |
| Date & Time | ✓ | ✓ | ✗ | ✗ | ✓ |
| Number | ✓ | ✓ | ✗ | ✗ | ✓ |
| Currency | ✓ | ✓ | ✗ | ✗ | ✓ |
| Dropdown | ✓ | ✓ | ✗ | ✓ | ✗ |
| ✓ | ✓ | ✓ | ✗ | ✓ | |
| Checkbox | ✓ | ✓ | ✗ | ✗ | ✗ |
| Phone Number | ✓ | ✓ | ✓ | ✗ | ✓ |
| Link | ✓ | ✓ | ✓ | ✗ | ✓ |
| JSON | ✗ | ✗ | ✗ | ✗ | ✗ |
| Vector | ✓ | ✗ | ✗ | ✗ | ✗ |
| Sparse Vector | ✓ | ✗ | ✗ | ✗ | ✗ |
| Half Vector | ✓ | ✗ | ✗ | ✗ | ✗ |
| ID | ✓ | ✓ | ✗ | ✗ | ✓ |
| Encrypted |