On Sun, Jun 20, 2010 at 7:41 PM, P Kishor <punk.k...@gmail.com> wrote:

> Once again, did you try Igor's suggestion? Exactly as he suggested?
> Don't know if it will work or not, but this I can say -- if there is
> one person in the entire SQL world you should listen to very
> carefully, it is Igor. There is never any wasted words in his
> suggestion, and his is almost always the correct solution. Try it,
> then report back.

With respect to Igor, you are not going to find anyone that stands up
and listens to EXACTLY what he said faster than I do!  Igor was
absolutely vital in my understanding of some Windows COM development
which is a corner stone of my application.  I only wish I knew a small
faction of what he knows!

With that said, I did try exactly what he said, I think.  Here is what I tried:

SELECT FolderId, ImageId, instertedon FROM V_FAVORITES_SELECTED
  WHERE case when instertedon > julianday(@time) then
findLargeImage(@path, FolderId, ImageId) else 0  end;

I am getting the same results as I did with my query, it is running
through the whole result set, calling the extended function on each
row.

> iirc, LIMIT 1 is applied *after* the WHERE clause is satisfied. In
> other words, the entire result set is returned, and then it is
> LIMITed. So, the behavior is correct.

I know there is a huge amount of math and science behind how SQL
optimizers work, so I am looking for a better understanding of how
things work: Why can't the optimizer use the LIMIT X as a way to
short-circuit the building of the WHERE clause?  It seems logical, but
since that is not the case, I am sure there is a reason why it isn't
the case, does anyone know that reason or can provide me an example of
why the WHERE clause needs to be fully satisfied first?

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

Reply via email to