[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sqlite-users
Subject:    Re: [sqlite] SQLite version 3.8.2 running 2.5x faster for some queries.
From:       Richard Hipp <drh () sqlite ! org>
Date:       2013-11-23 11:18:29
Message-ID: CALwJ=MyVkwFDJsc03D=fj-5oMqnQWtg7dM3A9QqmGV6NA23KSQ () mail ! gmail ! com
[Download RAW message or body]

On Sat, Nov 23, 2013 at 5:26 AM, Pepijn Van Eeckhoudt <
pepijn@vaneeckhoudt.net> wrote:

> Is datetime special in thuis context or will constant expression hoisting
> like this happen for any function?
>

SQLite must know that the function always gives the same output given the
same inputs.  No every function works that way.  Counterexamples include
random() and last_insert_rowid().  But most built-in functions are
factorable in the same way that datetime() is.

Currently there is no API to designate an application-defined function as
being "constant" in the sense that it always generates the same output
given the same inputs.  Hence, SQLite assumes the worst about
application-defined functions and never tries to factor them out of the
inner loop.  Probably we should add a new API that allows the application
to state auxiliary properties about application-defined functions (such as
whether or not it is "constant", whether or not it can return NULL, whether
or not it might change the encoding of its input parameters, etc.)  But
that has not been done yet.


-- 
D. Richard Hipp
drh@sqlite.org
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic