pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Craig Ringer <craig@postnewspapers.com.au>
To: Pavel Stehule <pavel.stehule@gmail.com>
Cc: Ivan Sergio Borgonovo <mail@webthatworks.it>
Cc: pgsql-sql@postgresql.org
Subject: Re: short-cutting if sum()>constant
Date: Thu, 24 Dec 2009 00:02:41 +0800
Message-ID: <4B323F21.3020007@postnewspapers.com.au> (raw)
In-Reply-To: <162867790912230352v5b6e395fm1880111c04eaa626@mail.gmail.com>
References: <20091222133527.3007bd96@dawn.webthatworks.it>
	<162867790912221147r7e3041fej44332a05faf915d6@mail.gmail.com>
	<20091223000031.54ad09b5@dawn.webthatworks.it>
	<20091223010940.51c5c069@dawn.webthatworks.it>
	<20091223024635.48d66554@dawn.webthatworks.it>
	<162867790912222338v73261b73u5c4e88a5ce85918f@mail.gmail.com>
	<20091223115628.1709caf5@dawn.webthatworks.it>
	<162867790912230352v5b6e395fm1880111c04eaa626@mail.gmail.com>

Pavel Stehule wrote:

> The problem is massive cycle. Plpgsql really isn't language for this.
> This interpret missing own arithmetic unit. So every expression is
> translated to SELECT statement
> 
> IF a > c ~ SELECT a > c
> a = a + 1 ~ SELECT a + 1
> 
> these queries are executed in some special mode, but still it is more
> expensive than C a = a + 1

... and may have different rules, so you can't just write a simple "map
expressions to C equivalents" arithmetic evaluator.

It's also far from easy to just translate PL/PgSQL to directly
machine-executable code as you suggested, by the way. It'd really
require a just-in-time compiler akin to what Java uses, though the
ability to compile once and cache would help get rid of some of the
complexity of Java's.

It'd quickly become attractive to just use PL/Java instead, or write
your own C-language function and LOAD it.

--
Craig Ringer



view thread (23+ messages)  latest in thread

Message-ID: <4B323F21.3020007@postnewspapers.com.au>
Permalink:  ../4B323F21.3020007@postnewspapers.com.au/
Also on:    postgresql.org/message-id/4B323F21.3020007@postnewspapers.com.au

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: craig@postnewspapers.com.au, pavel.stehule@gmail.com, mail@webthatworks.it
  Subject: Re: short-cutting if sum()>constant
  In-Reply-To: <4B323F21.3020007@postnewspapers.com.au>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox