On Fri, Sep 6, 2013 at 5:51 PM, Simon Davies
<simon.james.dav...@gmail.com>wrote:

> On 6 September 2013 16:38, Pepijn Van Eeckhoudt <pep...@vaneeckhoudt.net>
> wrote:
> > Hi,
> >
> > In the extension I'm developing (https://bitbucket.org/luciad/libgpkg)
> > I'm currently adding support for queries like:
> > select Distance(
> >   GeomFromText('Point(13.457 3)'),
> >   geometry
> > ) from table;
> >
> > GeomFromText takes a string and outputs a geometry blob
> > Distance takes two geometry blobs and returns a double
> >
> > In order to speed up the distance function I was wondering if I could
> > use aux_data to cache the parsed version of the first parameter since
> > this remains the same for every call. So far I haven't been able to get
> > this to work though, aux_data is always NULL, no matter what I try.
> >
> > My hunch is that this is because the first parameter is the result of a
> > function call which could in theory return different values for each row
> > even if the input parameters are constant. Is that correct?
> >
> > Are there any other ways to kind of memoize the GeomFromText function
> > (or the parameters to distance) besides aux_data?
>
> select Distance( constGeom, geometry ) from table, (select
> GeomFromText('Point(13.457 3)') as constGeom );
>

Clever. Thanks for that.

Or make your Distance function implementation do the GeomFromText
implicitly, with a bit of duck-typing.

You can test the argument's type, if blob use it as-is (hoping it's a
"geometry" blob in all cases), and if text, do the GeomFromText()
implicitly.

Since it's back to being a (text) constant, you can use aux_data again. --DD
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to