POST /models/instances/query and POST /models/instances/sync from the Instances group of the API reference. The request debug object sets configuration options, and the response debug object lists the notices.
Enable debug notices
To enable debug notices in your queries:Add debug configuration to your request
debug object to your API request to activate debug notices:Adjust timeout if needed
Understand grades and profiling
Debug notices highlight both positive and negative aspects of your query execution. They warn about potential performance issues and confirm when your query is well optimized.Grades
Each debug notice includes a grade that shows the importance or impact of the notice. Use this grading system to prioritize issues and recognize good practices:profile: true to see the full spectrum, including critical warnings (E) and strong positive confirmations (A). Profiling provides deeper insights for more accurate grading.Enable profiling
Theprofile option enables detailed query profiling, which gathers runtime statistics like execution timing and resource usage for each query part.
Profiling focuses on internal diagnostics, and you must disable query results by setting emitResults to false. Use this analysis for complex queries to uncover hidden performance bottlenecks.
To activate profiling:
Configure debug with profiling enabled
Request execution plans
Request the underlying PostgreSQL execution plan as part of debug notices by enabling the appropriate debug options. The execution plans show how the query processes at the database level. Execution plans help you analyze and diagnose query performance issues. If you have advanced PostgreSQL knowledge, you can also use these plans to understand query execution strategy and identify optimizations. To include execution plans:Enable includePlan in debug configuration
Request translated queries
Request the underlying query representation by enabling the translatedQuery debug option. This feature is intended for advanced debugging. To include the translated query:Enable translatedQuery in debug configuration
Handle common debug notices
This section focuses on specific debug notices the API returns and how to resolve them.Quick reference
sortNotBackedByIndex
Problem: Your query uses a sort order without a cursorable index. The system performs an in-memory sort at query time, which increases resource usage and slows performance as data scales.
Solution: Ensure your data model includes a cursorable index that matches your query’s sort order. This matters especially when sorting by multiple properties. Your query’s sort order must exactly match the property order in the index for the database to use it efficiently.
To resolve this issue:
Identify the sort order in your query
"container" has a compound index on properties A,B in that order. The order matters, and an index on B,A won’t work.Create the matching cursorable index
models/containers:index-identifier with an appropriate identifier for your index.suggestedCursorableSort
Problem: Your filter and sort don’t exactly match a cursorable index, but an existing cursorable index can serve the query if you use a slightly different sort. Without that sort, the query engine can’t paginate by reading one contiguous range of the index.
Solution: Use the suggestedSort from the notice as the full sort of the result expression. Among the rows your filter returns, the suggested sort keeps the order of your original sort. It prepends properties that your equality filters already fix to one value, and appends properties that only break ties. If your query has no sort, the notice proposes one, and the notice has no originalSort.
To resolve this issue:
Read the suggested sort from the notice
Pump has a cursorable index statusName on properties status, name, and serialNumber. Your query filters on status with equals and sorts by name. The notice suggests a sort that matches the index. These are the relevant fields of the notice:Use the suggested sort in your query
suggestedSort. Keep all properties, their order, directions, and nullsFirst values. Removing or reordering a property can make the sort non-cursorable again.The properties in suggestedSort reference containers. If your query uses views, replace each property reference with the matching view property, for example ["space", "PumpView/v1", "name"].unindexedThrough
Problem: Your query uses a through clause to traverse a direct relation. This notice appears when the traversal direction requires a missing index. Traversing a direct relation inwards requires an index on the relation’s target. Without it, the query scans many nodes to find the ones pointing to the source, which is inefficient and won’t scale.
Solution: Define an index on the property that is the target of the inwards direct relation.
To resolve this issue:
Identify the inwards relation in your query
Create an index on the relation property
sortNotBackedByIndex section.filterIncompatibleWithCursorableIndexScan
Problem: A cursor-paginated result expression has a filter that can’t be served by one contiguous scan of a cursorable index. Instead of resuming from the cursor position in the index, the query engine may have to scan and discard rows again for every page.
Solution: Rewrite the filter so that it fits a single cursorable index scan, without changing what the query returns. A compatible filter:
- Combines conditions with
andonly. - Uses properties from a single container. A filter on
spacealongside that container is fine. - Has any number of
equalsandinconditions. - Has
range,prefix, orexistsconditions on at most one property.
reasons field of the notice lists what makes the filter incompatible:
equals and in properties, followed by the range property and the sort properties, must also exist. See sortNotBackedByIndex to create one.
significantPostFiltering
Problem: The query engine processed many intermediate rows before filtering them to the final result set. This is inefficient because significant work goes to data that gets discarded. This happens when filters aren’t selective enough in early stages of a chained query.
Solution: Review your query to introduce more selective filters earlier. Use your knowledge about the data graph to narrow intermediate results as much as possible.
To resolve this issue:
Review your query for late filtering
Move filters earlier in the query
significantHasDataFiltering
Problem: A hasData filter applies to a view composed of many underlying containers. To satisfy the filter, the query engine may perform a join operation for each container to check for data existence. This becomes computationally expensive and slows your query.
Solution: Help the query planner optimize your query by adding requires constraints to container definitions used in the query. If you know your data model, for example, that data presence in one container implies data presence in another, use this to help the query engine prune unnecessary joins.
To resolve this issue:
Identify container dependencies in your data model
V that maps three containers: A, B, and C. You know that any node with data in container B or C is guaranteed to have data in container A.Without optimization, a hasData filter on V checks for data in A AND B AND C, resulting in multiple joins.Add requires constraints to dependent containers
B and C that point to A, you inform the query engine of this dependency. When it sees a hasData filter on V, it understands it only needs to check for data in container A. This simplifies the query, reduces joins, and can significantly improve performance.unfilteredContainerScan
Problem: A result expression that doesn’t chain from another result expression has hasData filters, but no filter on any property in the matched containers. hasData only checks that an instance has data in a container, so the query engine reads every instance in those containers. The cost grows with the size of the containers, not with the size of the result.
Solution: Narrow the scan with a filter on a property in one of the matched containers:
- Add a selective filter, preferably on an indexed property, in one of the containers that
hasDatamatches. - Remove
hasDatafilters that the query doesn’t need to return the right instances.
requires constraints, as described in significantHasDataFiltering, remove redundant joins but don’t make the scan selective. You still need a property filter to resolve this notice.
syncMissingSpaceFilter
Problem: A sync result expression doesn’t filter on a single space. To find the next page of changes, each sync request searches through changes in the entire project. In projects with many writes, this makes sync requests slow and can cause timeouts.
Solution: Add an equals filter on space to the sync expression, either as the whole filter or inside a top-level and. An in filter on space doesn’t resolve the notice, even with a single value.
To resolve this issue:
Add a space filter to the sync expression
["edge", "space"].Run one sync for each space