Re: Highly Efficient Custom Sorting - Mailing list pgsql-performance

From Eliot Gable
Subject Re: Highly Efficient Custom Sorting
Date
Msg-id AANLkTini3gqeePTScOPmmtSUTpKlQgVX4zFux4yvwQfg@mail.gmail.com
Whole thread Raw
In response to Re: Highly Efficient Custom Sorting  (Eliot Gable <egable+pgsql-performance@gmail.com>)
Responses Re: Highly Efficient Custom Sorting
List pgsql-performance
On Tue, Jul 6, 2010 at 4:17 PM, Eliot Gable <egable+pgsql-performance@gmail.com> wrote:

On Tue, Jul 6, 2010 at 4:00 PM, Joe Conway <mail@joeconway.com> wrote:


This approach works, but you could also use the SFRM_Materialize mode
and calculate the entire result set in one go. That tends to be simpler.
See, for example crosstab_hash() in contrib/tablefunc for an example.

FWIW, there are also some good examples of array handling in PL/R, e.g.
pg_array_get_r() in pg_conversion.c


 Thanks. That looks like less code and probably will be slightly more efficient.

I just got my first test of the new C-based function compiled and loaded into the server. The first time it is called, I see it correctly print the priority of each of the five rows of the array that I passed to it:

Got priority 1.
Got priority 1.
Got priority 1.
Got priority 1.
Got priority 1.
CONTEXT: ERROR
CODE: XX000
MESSAGE: cache lookup failed for type 7602245
---------------------------------------------------------------------------

I assume this "cache lookup" error is because I am not actually returning any results (or even NULL) at the end of the function call. If it means something else, please let me know.

Do I need to somehow force the server to unload and then re-load this .so file each time I build a new version of it? If so, how do I do that? Can I just re-run the "create or replace function" SQL code again to make that happen? In every other system I have dealt with where I build a module, I have some way to unload the module and force it to load again; but I don't see a mention of that in the PostgreSQL documentation.

Thanks again to everyone who has provided feedback.

--
Eliot Gable

pgsql-performance by date:

Previous
From: Ranga Gopalan
Date:
Subject: Re: Question about partitioned query behavior
Next
From: Tom Lane
Date:
Subject: Re: Highly Efficient Custom Sorting