Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Toadx-0000Tu-An for pgsql-performance@arkaria.postgresql.org; Fri, 28 Dec 2012 14:10:37 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1Toadw-0007Yt-Br for pgsql-performance@arkaria.postgresql.org; Fri, 28 Dec 2012 14:10:36 +0000 Received: from magus.postgresql.org ([87.238.57.229]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Toadv-0007Yn-Fc for pgsql-performance@postgresql.org; Fri, 28 Dec 2012 14:10:35 +0000 Received: from cl-262.qas-01.us.sixxs.net ([2001:4830:1600:105::2] helo=tamriel.snowman.net) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Toadr-0002uT-QG for pgsql-performance@postgresql.org; Fri, 28 Dec 2012 14:10:33 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id D17FF22D15; Fri, 28 Dec 2012 09:10:29 -0500 (EST) Date: Fri, 28 Dec 2012 09:10:29 -0500 From: Stephen Frost To: Pavel Stehule Cc: Vitalii Tymchyshyn , Jeff Janes , Charles Gomes , Ondrej =?utf-8?Q?Ivani=C4=8D?= , "pgsql-performance@postgresql.org" Subject: Re: Performance on Bulk Insert to Partitioned Table Message-ID: <20121228141029.GI16126@tamriel.snowman.net> References: <20121227190019.GC16126@tamriel.snowman.net> <20121228124141.GG16126@tamriel.snowman.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="4BlIp4fARb6QCoOq" Content-Disposition: inline In-Reply-To: X-Editor: Vim http://www.vim.org/ X-Info: http://www.snowman.net X-Operating-System: Linux/3.2.0-4-amd64 (x86_64) X-Uptime: 09:02:51 up 64 days, 12:26, 7 users, load average: 0.08, 0.13, 0.13 User-Agent: Mutt/1.5.21 (2010-09-15) X-Pg-Spam-Score: -1.9 (-) 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 --4BlIp4fARb6QCoOq Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 2012/12/28 Vitalii Tymchyshyn : > Why so? Basic form "case lvalue when rvalue then out ... end" is much like > switch. Sorry, to be honest, I missed that distinction and didn't expect that to work as-is, yet apparently it does. Does it currently perform the same as an if/elsif tree or is it implemented to actually use a table lookup? * Pavel Stehule (pavel.stehule@gmail.com) wrote: > please, look to plpgsql source code. PL/pgSQL is too simply and has > not own arithmetic unit - all is transformed to SELECTs, has not any > optimization. But is really short and maintainable. I was thinking we'd actually do this for all CASE statements, those in plpgsql and those in regular SQL, if it's possible to do. Hopefully it'd be possible to do easily in plpgsql once the SQL-level CASE is done. > These SELECTs are evaluated only when it is necessary - but it is > evaluated by PostgreSQL expression executor - not by PL/pgSQL directly > - PL/pgSQL cannot process constant by self. Right, but I wonder if we could pass the entire CASE tree to the executor, with essentially pointers to the code blocks which will be executed, and get back a function which we can call over and over that takes whatever the parameter is and returns the 'right' pointer? > So any enhancing needs PL/pgSQL redesign and I am not sure, so this > use case has accurate benefit, because expression bottleneck is only > one part of partitioning triggers bottleneck. More - if you need > really fast code, you can use own code in C - and it be 10x times > faster than any optimized PL/pgSQL code. And using C triggers in > PostgreSQL is not terrible work. It's quite a bit of work for people who don't know C or are (understandably) concerned about writing things which can easily segfault the entire backend. > Using plpgsql row triggers for partitioning is not good idea - it is > just work around from my perspective, and we should to solve source of > problem - missing native support. I agree that native partitioning would certainly be nice. I was really hoping that was going to happen for 9.3, but it seems unlikely now (unless I've missed something). Thanks, Stephen --4BlIp4fARb6QCoOq Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iEYEARECAAYFAlDdqFUACgkQrzgMPqB3kigjPgCgkbYdnRXiDnMX80qO73yy+bP9 Q5MAmwaUZXNW3Rh4Pu+bjMQBHTbElQye =yjcz -----END PGP SIGNATURE----- --4BlIp4fARb6QCoOq--