Re: Losing memory references - SRF + SPI

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Anderson Carniel <accarniel(at)gmail(dot)com>
Cc: Joe Conway <mail(at)joeconway(dot)com>, PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Losing memory references - SRF + SPI
Date: 2016-05-15 06:02:15
Message-ID: CAB7nPqR1ABv1a9LAeYHXodoCjnaQuJjXCZf-zVet19rKDvXn1g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, May 15, 2016 at 10:22 AM, Anderson Carniel <accarniel(at)gmail(dot)com> wrote:
> Thank you very much Joe.
>
> I have followed the crosstab() implementation and understood the idea of per
> query memory context. Now, I am using a unique SPI instance (which I perform
> several sql queries), process the result, transform my result into a
> tuplestore, close the SPI and done. It works perfectly.
>
> I have a curiosity with regard to the tuplestore: is there a problem with
> performance if my tuplestore form a big table with million of tuples? Other
> question is regarding to SPI: is there a problem to use only one instance
> of SPI (for instance, if multiple users call the same function)?

When using a tuplestore, one concern for performance is the moment
data is going to spill into disk, something that is set with maxKBytes
in tuplestore_begin_heap(). Using work_mem is the recommendation,
though you could tune it better depending on your needs.
--
Michael

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2016-05-15 06:34:58 Re: [HACKERS] Re: [HACKERS] Re: [HACKERS] Windows service is not starting so there’s message in log: FATAL: "could not create shared memory segment “Global/PostgreSQL.851401618”: Permission denied”
Previous Message Tom Lane 2016-05-15 03:37:53 Re: 10.0