TheDocumentation Index
Fetch the complete documentation index at: https://docs.ditto.live/llms.txt
Use this file to discover all available pages before exploring further.
PROFILE statement executes a SELECT query and appends detailed profiling information to the result set, including the query execution plan annotated with document counts and timing data.
Profiling information is stored in the virtual collection
system:completed_requests. You can also query profiling and request history data directly using the virtual collections system:active_requests and system:request_history. See Virtual Collections for more details.Syntax
DQL
How It Works
When you execute aPROFILE statement:
- The query runs normally and returns all result documents
- An additional result is appended containing the
system:completed_requestscache entry - This entry includes the query plan with profiling information (document counts, timing)
Using PROFILE
DQL
- All matching documents
- A final result containing the annotated query plan with profiling data
Profiling Information
The profiling result includes:- Document counts: How many documents were processed at each step of the plan
- Timing information: How long each operation took
- Query plan structure: The full execution plan showing scans, filters, projections, etc.
- Index usage: Which indices (if any) were used
Example Output Structure
The profiling information is returned as the final result in the result set and typically includes:Using Profiling Data
Profiling data helps you:- Identify bottlenecks: See which operations are taking the most time
- Verify index usage: Confirm your query is using the expected indices
- Understand query execution: See how the planner executes your query
- Optimize performance: Make informed decisions about index creation and query structure
Code Examples
PROFILE vs #profile Directive
ThePROFILE statement is equivalent to using the #profile directive:
DQL
Limitations
PROFILEonly supportsSELECTstatements- The profiling data is appended as the last result, so you need to handle it separately from your query results
- Profiling may add slight overhead to query execution
See Also
- EXPLAIN - View query execution plans without running the query
- Directives - Control query planner behavior
- Access Paths - Understanding query execution strategies
- Indexing - Creating indices to improve query performance