On Mon, Aug 1, 2011 at 11:04 AM, David Fetter <david@fetter.org> wrote:
> SQL is Turing-complete, so the chances are excellent that it's
> possible to express that algorithm in it. ;)
>
> Look into common table expressions for iteration/recursion, and
> windowing functions, commonly used for time series.
>
> http://www.postgresql.org/docs/current/static/queries-with.html
> http://www.postgresql.org/docs/current/static/tutorial-window.html
That doesn't guarantee that it can be expressed efficiently, though.
I think the OP may be going overboard by trying to bypass SPI, but
putting the logic inside the server seems like it could well be
worthwhile.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company