Re: Imperative Query Languages

From: Jason Dusek <jason(dot)dusek(at)gmail(dot)com>
To: Chris Travers <chris(dot)travers(at)gmail(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Imperative Query Languages
Date: 2017-07-05 06:34:44
Message-ID: CAO3NbwMBWfzOx8X9WWR87m-iDfimhb55uxsChJ3n-ZDW2rfZtg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, 4 Jul 2017 at 23:22 Chris Travers <chris(dot)travers(at)gmail(dot)com> wrote:

> Having done a lot of SQL optimisation stuff I have doubts that this is
> possible. The problem is that it is much easier to go from a declarative
> to an imperative plan than it is to go the other way. In fact sometimes we
> use SQL the way your first code works and then it is often a problem.
>
> For example, consider the difference between an EXISTS and an IN query, or
> between an INNER JOIN and a LATERAL JOIN. PostgreSQL's optimiser is
> amazing at identifying cases where these are equivalent and planning
> accordingly, but it is extremely easy to get just outside the envelope
> where the optimiser gives up and has to default back to an imperative
> interpretation of these. Proving that two imperative approaches are
> equivalent is a lot harder than proving that two different imperative
> approaches implement the same declarative request. In other words, going
> imperative -> declarative strikes me as a far, far harder problem than the
> other way.
>
> Also I have done a little bit of work on Apache Spark and there it is
> extremely important to understand the imperative side of the data flow in
> that case (what is partitioned and what is not).
>

I can not argue these points with you; but Fortress is a good example of
imperative looking code that translates to a functional/declarative core;
as indeed is monadic or applicative code. LINQ is a more recent and
widespread example -- though not encompassing an entire language -- of
something that has an imperative form while being declarative under the
hood. Scala's for comprehensions -- more or less monad comprehensions --are
another.

With regards to Spark, I assume for comprehensions are an important part of
the interface?

Kind Regards,
Jason

>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Chris Travers 2017-07-05 06:41:15 Re: Imperative Query Languages
Previous Message Chris Travers 2017-07-05 06:22:27 Re: Imperative Query Languages