Skip site navigation (1) Skip section navigation (2)

Access to Row ID information in Functions

From: "Paul Ramsey" <pramsey(at)cleverelephant(dot)ca>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Access to Row ID information in Functions
Date: 2008-04-01 18:37:40
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers
In PostGIS, we have a problem, in that spatial operations are very
costly, CPUwise.

We have hit on a nifty enhancement recently, which was to recognize
that when processing multiple rows, in joins or with literal
argouments, for most functions of the form GeometryOperation(A, B), A
(or B) tended to remain constant, while the other argument changed.
That meant that we could build an "optimized" form of the
more-constant argument (using internal index structures on the object
segments) that allows testing the changing argument much more quickly.

The "optimized" form gets cached and retrieved from a memory context.
Each time the function is run within a statement it checks the cache,
and sees if one of its arguments are the same as the last time around.
If so, it uses the prepared version of that argument. If not, it
builds a new prepared version and caches that.

The key here is being able to check the identify of the arguments...
is this argument A the same as the one we processed last time? One way
is to do a memcmp.  But it seems likely that PgSQL knows exactly
whether it is running a nested loop, or a literal, and could tell
somehow that argument A is the same with each call.

For lack of a better term, if we knew what the "row id" of each
argument was as the function was called, we could skip the memcmp
testing of geometric identity (which gets more expensive precisely at
the time our optimization gets more effective, for large arguments)
and just trust the row id as the guide of when to build and cache new
"optimized" representations.

Any guidance?




pgsql-hackers by date

Next:From: Simon RiggsDate: 2008-04-01 19:03:18
Subject: Re: Improve shutdown during online backup
Previous:From: Aidan Van DykDate: 2008-04-01 18:20:39
Subject: Re: Several tags around PostgreSQL 7.1 broken

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group