SQLite Forum

Building SQLIte3 wiuth debug options fails on UBUNTU
Login
> Is there documentation how to interpret the .selecttrace log

No.  The ".selecttrace" command is designed for use by the developers
when debugging the code generator.  The flags that ".selecttrace" accepts
and the output from ".selecttrace" changes from one release to the next.
We can, and often do, change the behavior of ".selecttrace" depending on
what problem we are working on and the data structure visualization needs
associated with that problem.

The general idea remains the same, however.  The sqlite3Select() routine
is invoked with a pointer to a Select object.  A Select object is the head
of a tree that describes a single SELECT statement.  This Select object
will be processed and transformed in order to generate byte-code to implement
the SELECT statement.  The ".selecttrace" command outputs snapshots of the
Select object and all of its substructure as the object is processed.

Usually we invoke ".selecttrace 0xffff".  That turns on all of the tracing
capabilities.  When we run a query.  The first graph shows the raw parse
tree straight out of the parser.  The first transformation is to walk the
graph and resolve all of the identifiers and expand "*" operators in the
result set.  After this name resolution, the graph is redrawn.  Then
various optimizations are applied, which typically transform the graph
further.

Note that when there are subqueries, the sqlite3Select() routine is invoked
recursively.  Each entry and exit from sqlite3Select() is announced.

It is usually necessary to be looking at the source code in order to understand
the details of what the .selecttrace output means.