dszhang wrote:
>
> by now the forst query is work well, but the second query is not,the second 
> query take about 5 times longer than the first one.i want to konw why?
> i think may be the engine haven't use the index ,so i would prefer to ues 
> EXPLAIN syntax,but i don't know how to use it in C API and how to get the  
> EXPLAIN result in C API.
>  would anyone give me some idear about this,thans a lot.
>
>   
You can use either EXPLAIN or EXPLAIN QUERY PLAN as a prefix to any SQL
statement (typically a query though). These convert the statement into a
query that returns rows explaining how the query will be implemented.

EXPLAIN returns five columns as shown below (with headers on). The
opcodes of the vdbe (virtual database engine) machine are documented at
http://www.sqlite.org/opcode.html and http://www.sqlite.org/vdbe.html

sqlite> explain select * from t;
addr opcode p1 p2 p3
---------- ---------- ---------- ---------- ----------
0 Goto 0 11
1 Integer 0 0
2 OpenRead 0 2
3 SetNumColu 0 2
4 Rewind 0 9
5 Column 0 0
6 Column 0 1
7 Callback 2 0
8 Next 0 5
9 Close 0 0
10 Halt 0 0
11 Transactio 0 0
12 VerifyCook 0 1
13 Goto 0 1
14 Noop 0 0

An EXPLAIN QUERY PLAN returns three columns. The output of explain query
plan is not documented (to the best of my knowledge anyway), but is
fairly self explanatory. It shows the order that tables are scanned and
which indexes, if any, are used to speed up the scans.

sqlite> explain query plan select * from t;
order from detail
---------- ---------- ----------
0 0 TABLE t

HTH
Dennis Cote

-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to