W3cubDocs

/SQLite

Prepared Statement Scan Status Opcodes

#define SQLITE_SCANSTAT_NLOOP    0
#define SQLITE_SCANSTAT_NVISIT   1
#define SQLITE_SCANSTAT_EST      2
#define SQLITE_SCANSTAT_NAME     3
#define SQLITE_SCANSTAT_EXPLAIN  4
#define SQLITE_SCANSTAT_SELECTID 5

The following constants can be used for the T parameter to the sqlite3_stmt_scanstatus(S,X,T,V) interface. Each constant designates a different metric for sqlite3_stmt_scanstatus() to return.

When the value returned to V is a string, space to hold that string is managed by the prepared statement S and will be automatically freed when S is finalized.

SQLITE_SCANSTAT_NLOOP
The sqlite3_int64 variable pointed to by the V parameter will be set to the total number of times that the X-th loop has run.

SQLITE_SCANSTAT_NVISIT
The sqlite3_int64 variable pointed to by the V parameter will be set to the total number of rows examined by all iterations of the X-th loop.

SQLITE_SCANSTAT_EST
The "double" variable pointed to by the V parameter will be set to the query planner's estimate for the average number of rows output from each iteration of the X-th loop. If the query planner's estimates was accurate, then this value will approximate the quotient NVISIT/NLOOP and the product of this value for all prior loops with the same SELECTID will be the NLOOP value for the current loop.

SQLITE_SCANSTAT_NAME
The "const char *" variable pointed to by the V parameter will be set to a zero-terminated UTF-8 string containing the name of the index or table used for the X-th loop.

SQLITE_SCANSTAT_EXPLAIN
The "const char *" variable pointed to by the V parameter will be set to a zero-terminated UTF-8 string containing the EXPLAIN QUERY PLAN description for the X-th loop.

SQLITE_SCANSTAT_SELECT
The "int" variable pointed to by the V parameter will be set to the "select-id" for the X-th loop. The select-id identifies which query or subquery the loop is part of. The main query has a select-id of zero. The select-id is the same value as is output in the first column of an EXPLAIN QUERY PLAN query.

See also lists of Objects, Constants, and Functions.

SQLite is in the Public Domain.
https://sqlite.org/c3ref/c_scanstat_est.html