Access to Row ID information in Functions

Поиск
Список
Период
Сортировка
От Paul Ramsey
Тема Access to Row ID information in Functions
Дата
Msg-id 30fe546d0804011137k3e0895c6i42b60e050ddfd21d@mail.gmail.com
обсуждение исходный текст
Ответы Re: Access to Row ID information in Functions  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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?

Thanks,

Paul


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Aidan Van Dyk
Дата:
Сообщение: Re: Several tags around PostgreSQL 7.1 broken
Следующее
От: Gregory Stark
Дата:
Сообщение: Re: [GENERAL] ANALYZE getting dead tuple count hopelessly wrong