On Sep 14, 2017, at 9:36 AM, Darko Volaric <li...@darko.org> wrote:
> 
> I don't support automatic CSE, I think it should be done manually.

So…you want a SQL profiler, then?  Like EXPLAIN?

I suppose there might be a market for a tool that takes a query string and 
spends a ridiculous amount of time analyzing it and rewrites it to run 
optimally on SQLite.  That sounds like something you’d expect to pay top dollar 
for, though, since you’re basically replacing the brain of a SQLite expert.

> is there a way of ensuring that a particular expression (or just function 
> call) will be guaranteed to be evaluated before any other in a particular 
> statement?

Pseudocode:

    INSERT INTO CacheTable.foo VALUES (SELECT FROM…) ;
    SELECT FROM ... WHERE CacheTable.foo = ...

Other than that, I doubt it.  SQL is a declarative language, which means it 
purposely does not define sequence points, in C parlance.  Without that 
property, SQL’s query planner would not have much of the freedom it does, which 
would be a very bad thing from the point of this thread.

Much of the reason a language like C takes so long to compile is that all those 
sequence point rules in the ISO C standard tie the compiler’s hands, requiring 
very clever analysis to figure out what optimizations are even legal.

Optimization efforts have gotten to the point that there are now C compilers 
that generate code that is correct according to the standard but which behaves 
in ways the average C programmer does not fully understand through extremely 
abstruse language lawyering.

For example:

    https://stackoverflow.com/questions/18195715/
    http://blog.llvm.org/2011/05/what-every-c-programmer-should-know.html

In the second link, scroll down to how the ISO C rule explained in the first 
link impacts the LLVM optimizer.  Were you aware of all these ramifications?

SQLite, having even more freedom in some ways than ISO C, probably does plenty 
that would surprise you if you knew about it.
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to