Re: Shared Constants in PLPGSQL

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: Tim Uckun <timuckun(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Shared Constants in PLPGSQL
Date: 2017-08-01 18:54:17
Message-ID: CAHyXU0yH10Wga6ebtNvsUotKbMRbUueAx5S856Jr7VahJs3QpA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Aug 1, 2017 at 8:29 AM, Tim Uckun <timuckun(at)gmail(dot)com> wrote:
> In my case I don't expect these constants to be changed on a regular basis.
> They will be set just once and that's it. I was thinking it would be just as
> easy to set them in a proc as it would be to set them in a table. By putting
> them in an immutable proc I can hopefully save a couple of compute cycles.

Sure. The point is, by having a proc return a table based composite
type, you can simplify changes down the line. Adding a new setting
can be done via ALTER. Changing a setting (should it become
necessary) can be done with an UPDATE. The immutable wrapping
function does eliminate some fetches and I would generally write that
wrapper.

merlin

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jeff Janes 2017-08-01 20:17:13 Re: Perfomance of IN-clause with many elements and possible solutions
Previous Message Dan Cooperstock at Software4Nonprofits 2017-08-01 18:35:11 Re: Problem compiling a C function on Windows - not finding _palloc0@4