I was able to find out the following information…
Indexing Overview in Nextworld
Each table in the platform has four primary sources of indexes:
1. Nextworld Default Indexes
These are automatically created by the system when a table is defined. They include:
- NwHeaderId
- NwExternalId
- NwId
The primary key for each table is built on NwId. Additionally, all default indexes — except for the NwId index — include nwNateId and nwTenantStripe.
2. Auto-Generated Indexes
Visible under the Auto Generated Indexes section on the Indexes tab in the Table Definition.
The system creates these indexes automatically when a field is added to a table with any of the following types:
- Table Lookup
- List Lookup
- Auto Number
- Translatable
Like default indexes, these also include nwNateId and nwTenantStripe automatically (unless the index is a base index).
3. User-Defined Indexes
These are indexes explicitly created by developers in the Table Definition.
Just like system-generated indexes, nwNateId and nwTeanantStripe are automatically added (unless the index is a base index).
Keep in mind that nwID is not included on user defined dexes by default, but could be useful to add in the case of joins. See section Join Indexes.
4. Workflow Indexes
If workflow is enabled for a table, the system automatically creates an index over:
- WorkflowCurrentState
- WorkflowCurrentStateType
Subtable Mains Indexes
To improve performance, the system now automatically adds the following fields to all user-defined and auto-generated indexes on subtable main tables:
Additionally, InternalSeq has been added to the NwHeaderId default index. Although default indexes aren’t user-visible, this change still contributes to query performance behind the scenes.
Join Indexes
In the case of table joins, the system automatically creates an index with nwID but its stores as text so it works better in certain situations versus others. For example, it’s helpuful for connecting the tables (joins), but it’s not great at filtering. In those cases, you might still need to create a more specific index that includes the other fields you’re filtering on.
Best Practices & Considerations
Indexing Is Nuanced
Due to the interconnected nature of data in the platform, indexing can be complex. Keep these key points in mind:
- NwHeaderId: Avoid creating unique indexes on this field in Detail tables. A unique index is only appropriate on Header tables or in rare 1:1 header-detail relationships. The standard header-detail pattern assumes a 1-to-many relationship so applying uniqueness at the Detail level contradicts this design. If a 1:1 mapping is required, a different construct should be explored.
- NwId: This is a unique-friendly field and ideal for identifying a single record. It is not included in user defined indexes by default, but including it manually in indexes can boost performance — particularly during JOINs that use a pattern like: (nwTenantStripe, nwNateId, childTable->DataItem = parentTable->NwId)
- When also applying filters (e.g., WHERE childTable->DataItem LIKE ‘bob%’), a compound index such as:
(nwTenantStripe, nwNateId, NwId, DataItem)
can enhance query performance by enabling the database to handle both the JOIN and the filter through the same index. This allows the database to use the index for both the JOIN and the filter condition.
Performance Considerations
There are various factors that affect whether a user defined index improves performance, for example, the physical storage size of the index. It’s important to weigh the trade-offs between index depth and performance gains. Adding more fields to an index increases its size, which can negatively impact performance in some cases.
Always test performance both with and without a user defined index to understand its actual impact. Indexes can significantly improve performance but must be evaluated in context.