Re: Highly Efficient Custom Sorting

From: Eliot Gable <egable+pgsql-performance(at)gmail(dot)com>
To: Joe Conway <mail(at)joeconway(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Merlin Moncure <mmoncure(at)gmail(dot)com>, Craig Ringer <craig(at)postnewspapers(dot)com(dot)au>, Craig James <craig_james(at)emolecules(dot)com>, pgsql-performance(at)postgresql(dot)org
Subject: Re: Highly Efficient Custom Sorting
Date: 2010-07-06 21:53:04
Message-ID: AANLkTini3gqeePTScOPmmtSUTpKlQgVX4zFux4yvwQfg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Tue, Jul 6, 2010 at 4:17 PM, Eliot Gable <
egable+pgsql-performance(at)gmail(dot)com <egable%2Bpgsql-performance(at)gmail(dot)com>>wrote:

>
> On Tue, Jul 6, 2010 at 4:00 PM, Joe Conway <mail(at)joeconway(dot)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

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Tom Lane 2010-07-06 22:21:24 Re: Highly Efficient Custom Sorting
Previous Message Ranga Gopalan 2010-07-06 21:02:22 Re: Question about partitioned query behavior