Re: short-cutting if sum()>constant - Mailing list pgsql-sql

From Craig Ringer
Subject Re: short-cutting if sum()>constant
Date
Msg-id 4B323F21.3020007@postnewspapers.com.au
Whole thread Raw
In response to Re: short-cutting if sum()>constant  (Pavel Stehule <pavel.stehule@gmail.com>)
Responses Re: short-cutting if sum()>constant
List pgsql-sql
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


pgsql-sql by date:

Previous
From: Ivan Sergio Borgonovo
Date:
Subject: Re: short-cutting if sum()>constant
Next
From: Pavel Stehule
Date:
Subject: Re: short-cutting if sum()>constant