Re: short-cutting if sum()>constant
От | Craig Ringer |
---|---|
Тема | Re: short-cutting if sum()>constant |
Дата | |
Msg-id | 4B323F21.3020007@postnewspapers.com.au обсуждение исходный текст |
Ответ на | Re: short-cutting if sum()>constant (Pavel Stehule <pavel.stehule@gmail.com>) |
Ответы |
Re: short-cutting if sum()>constant
|
Список | 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 по дате отправления: