On Oct 9, 2008, at 11:46 AM, Ken wrote:

> DRH,
> I noticed that the VDBE is doing a check for null Can this be removed?
>
> test script to show output:
> create table t (id integer not null, id2 integer);
> create index  t_idx on t (id);
> explain select id from t where id = 5;
>
>
> 0|Trace|0|0|0|explain select id from t where id = 5;|00|
> 1|Integer|5|1|0||00|
> 2|Goto|0|15|0||00|
> 3|SetNumColumns|0|2|0||00|
> 4|OpenRead|1|6|0|keyinfo(1,BINARY)|00|
> 5|SCopy|1|3|0||00|
> 6|IsNull|3|13|0||00|                        <-----------------------  
> IS this needed ???
> 7|Affinity|3|1|0|db|00|
> 8|MoveGe|1|13|3|1|00|
> 9|IdxGE|1|13|3|1|01|
> 10|Column|1|0|8||00|
> 11|ResultRow|8|1|0||00|
> 12|Next|1|9|0||00|
> 13|Close|1|0|0||00|
> 14|Halt|0|0|0||00|
> 15|Transaction|0|0|0||00|
> 16|VerifyCookie|0|7|0||00|
> 17|TableLock|0|5|0|t|00|
> 18|Goto|0|3|0||00|
>

It is needed when the query is something like:

     SELECT id FROM t WHERE id = ?

We could add lots of new logic to the code generator to try and  
suppress the OP_IsNull in cases where the non-nullness of the value  
could be determined at compile-time.  But OP_IsNull takes no  
measurable amount of time, so why clutter up the code base to do so?

You will get much better output from EXPLAIN if you first run the  
shell macro ".explain"

D. Richard Hipp
[EMAIL PROTECTED]



_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to