From: | Craig Ringer <craig(at)postnewspapers(dot)com(dot)au> |
---|---|
To: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
Cc: | Ivan Sergio Borgonovo <mail(at)webthatworks(dot)it>, pgsql-sql(at)postgresql(dot)org |
Subject: | Re: short-cutting if sum()>constant |
Date: | 2009-12-23 16:02:41 |
Message-ID: | 4B323F21.3020007@postnewspapers.com.au |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Pavel Stehule | 2009-12-23 16:04:37 | Re: short-cutting if sum()>constant |
Previous Message | Ivan Sergio Borgonovo | 2009-12-23 14:27:28 | Re: short-cutting if sum()>constant |