Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dCWaM-0007e4-6k for pgsql-performance@arkaria.postgresql.org; Sun, 21 May 2017 19:32:14 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dCWaL-0000RG-4Q for pgsql-performance@arkaria.postgresql.org; Sun, 21 May 2017 19:32:13 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dCWYZ-0005lK-OZ for pgsql-performance@postgresql.org; Sun, 21 May 2017 19:30:23 +0000 Received: from outgoing3.cpt4.host-h.net ([197.189.247.36]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dCWYV-0000r9-AH for pgsql-performance@postgresql.org; Sun, 21 May 2017 19:30:22 +0000 Received: from www20.cpt1.host-h.net ([197.221.2.20]) by antispam2-cpt4.host-h.net with esmtpsa (TLSv1.2:AES128-SHA:128) (Exim 4.86) (envelope-from ) id 1dCWYN-0004jj-Lm; Sun, 21 May 2017 21:30:14 +0200 Received: from 196-210-197-156.dynamic.isadsl.co.za ([196.210.197.156] helo=DMZHOST) by www20.cpt1.host-h.net with esmtpa (Exim 4.80) (envelope-from ) id 1dCWYK-0005D4-KK; Sun, 21 May 2017 21:30:08 +0200 Received: from P03867-RiaanS (Unknown [10.0.0.23]) by DMZHOST with ESMTPA ; Sun, 21 May 2017 21:29:54 +0200 Subject: Re: Bulk persistence strategy To: Tom Lane References: <04c901d2a753$f55de020$e019a060$@exa.co.za> <15c29aeedc8.27e1.e05fafc80f8daf1488764675043d44fb@exa.co.za> <32403.1495377186@sss.pgh.pa.us> Cc: pgsql-performance@postgresql.org From: Riaan Stander Message-ID: <0e47ae52-e80a-fd8e-021c-7c8cc0495b26@exa.co.za> Date: Sun, 21 May 2017 21:29:53 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <32403.1495377186@sss.pgh.pa.us> Content-Type: multipart/alternative; boundary="------------4EE339DE6BAE5F3F171E8FDC" X-Authenticated-Sender: smtprelay@exa.co.za X-Virus-Scanned: Clear (ClamAV 0.99.2/23405/Sun May 21 18:55:10 2017) X-Originating-IP: 197.221.2.20 X-SpamExperts-Domain: exa.co.za X-SpamExperts-Username: Authentication-Results: host-h.net; auth=pass (login) smtp.auth=@exa.co.za X-SpamExperts-Outgoing-Class: ham X-SpamExperts-Outgoing-Evidence: Combined (0.29) X-Recommended-Action: accept X-Filter-ID: s0sct1PQhAABKnZB5plbIWL5vMUYxb2kq1uspbfEA9+ihNzEqHRR3fXVWQ7SEawUiwQzKw+6v3Ca IMG6s7LqJJlV3j2ipgsAbbE1JvuwkkgZ4m00l3uPRdWwNfw+Po+GO76XSTAwtV4mg4i2ouCDa4AU hvIWAV5xUW/+gAh4vXpz0RHVGWQt+cn47pliXrxqRcOb18WfxGyg6Om6u4YYm0UFPnDINtptcBxh ZaFqmjWMytmwoSOAsUiZHL4elTOeW/T3iEdLQrEzANTH1RO+ZuWBOXp8nHKe0R+FkIqN7hlBaLCK i/3d82ndyQckqlk5z3irZHx8XwBM/aZ+josQAfUf9oDBqtClgM5jH/om1Q4tH6VyaEKKyFb3KuYS PtYeOngwKsK/v8O00LnH1NcGs0PkGda5olUXOJzJbtkypWIEPaEM6Ls9T603i0+693PcTRNgiCAA Q5x64LwjDkFRezYYB0K6DpInazve5ezQP+U2yPRk3H1E4ANRdN1BlPI5rJaWDcne6cToXniqtJYh 2fh2wfAJPI99az2gqFCIIfZ1+KzU7SnoXsKZpOw3kjuy3dvVP/kn/fqQjwto0FIhGpaGzcj+Mc5i sodBI9N2YC5aCjuBDzdB/sn9JnExigkZNff1J0V4Egf9XlsVRD9nnuidX4Ts4xdG+C13IyWeZaLD jVeW0gakOFUvWxP6t4hdlMG5FAt3n0MV9PNVLuAh0cEIwY8xWZC3kZZbO0Uf5TG5X3u97YLfFuPW aicDtNrQuCQdZLNhLwRrtF5z+7s1/t/VIeLbUrGXPGnBDeG6QE5hPdp0hgR346dI3RMDBCi65ZYI mXfy7mbINl5QOPWzq9t/CqWjvlO7AaQ3BW40eUX9jTNoRtEyv66AyXMFVSIH9jihx+Za/cV70jOJ zN2r4A== X-Report-Abuse-To: spam@antispammaster.host-h.net X-Pg-Spam-Score: -5.4 (-----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org This is a multi-part message in MIME format. --------------4EE339DE6BAE5F3F171E8FDC Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit > Riaan Stander writes: >> I've come up with generating functions on the go, but I'm concerned about >> the performance impact of this. I first wanted to use an anonoumys code >> block, but then I cannot do parameter binding from npgsql. >> ... >> Is there a better way I'm missing and is "temp" function creation in >> Postgres a big performance concern, especially if a server is under load? > The function itself is only one pg_proc row, but if you're expecting > to do this thousands of times a minute you might have to adjust autovacuum > settings to avoid bad bloat in pg_proc. > > If you're intending that these functions be use-once, it's fairly unclear > to me why you bother, as opposed to just issuing the underlying SQL > statements. > > regards, tom lane The intended use is use-once. The reason is that the statements might differ per call, especially when we start doing updates. The ideal would be to just issue the sql statements, but I was trying to cut down on network calls. To batch them together and get output from one query as input for the others (declare variables), I have to wrap them in a function in Postgres. Or am I missing something? In SQL Server TSQL I could declare variables in any statement as required. --------------4EE339DE6BAE5F3F171E8FDC Content-Type: text/html; charset=windows-1252 Content-Transfer-Encoding: 7bit
Riaan Stander <rstander@exa.co.za> writes:
I've come up with generating functions on the go, but I'm concerned about 
the performance impact of this. I first wanted to use an anonoumys code 
block, but then I cannot do parameter binding from npgsql.
...
Is there a better way I'm missing and is "temp" function creation in 
Postgres a big performance concern, especially if a server is under load?
The function itself is only one pg_proc row, but if you're expecting
to do this thousands of times a minute you might have to adjust autovacuum
settings to avoid bad bloat in pg_proc.

If you're intending that these functions be use-once, it's fairly unclear
to me why you bother, as opposed to just issuing the underlying SQL
statements.

			regards, tom lane

The intended use is use-once. The reason is that the statements might differ per call, especially when we start doing updates. The ideal would be to just issue the sql statements, but I was trying to cut down on network calls. To batch them together and get output from one query as input for the others (declare variables), I have to wrap them in a function in Postgres. Or am I missing something? In SQL Server TSQL I could declare variables in any statement as required.


--------------4EE339DE6BAE5F3F171E8FDC--