Re: Proposing WITH ITERATIVE

2020-04-30 Thread Jeff Davis
On Tue, 2020-04-28 at 11:57 -0400, Jonah H. Harris wrote: > Yeah, in that specific case, one of the other implementations seems > to carry the counters along in the executor itself. But, as not all > uses of this functionality are iteration-count-based, I think that's > a little limiting. Using a

Re: Proposing WITH ITERATIVE

2020-04-30 Thread Fabien COELHO
Hello, more random thoughts about syntax, semantics, and keeping it relational. While I'm not a huge fan of it, one of the other databases implementing this functionality does so using the syntax: WITH ITERATIVE R AS '(' R0 ITERATE Ri UNTIL N (ITERATIONS | UPDATES) ')' Qf Where N in

Re: Proposing WITH ITERATIVE

2020-04-29 Thread Jonah H. Harris
On Wed, Apr 29, 2020 at 5:54 PM Jonah H. Harris wrote: > On Wed, Apr 29, 2020 at 4:50 PM Corey Huinker > wrote: > >> Having both WHERE and WHILE might look awkward. >>> >> >> Maybe an UNTIL instead of WHILE? >> > > While I'm not a huge fan of it, one of the other databases implementing > this

Re: Proposing WITH ITERATIVE

2020-04-29 Thread Jonah H. Harris
On Wed, Apr 29, 2020 at 4:50 PM Corey Huinker wrote: > Having both WHERE and WHILE might look awkward. >> > > Maybe an UNTIL instead of WHILE? > While I'm not a huge fan of it, one of the other databases implementing this functionality does so using the syntax: WITH ITERATIVE R AS '(' R0

Re: Proposing WITH ITERATIVE

2020-04-29 Thread Corey Huinker
> > > > Perhaps something like this would be more readable > > > > WITH t AS ( > >UPDATE ( SELECT 1 AS ctr, 'x' as val ) > >SET ctr = ctr + 1, val = val || 'x' > >WHILE ctr <= 100 > >RETURNING ctr, val > > ) > > > > The notion of an UPDATE on an ephemeral subquery isn't that

Re: Proposing WITH ITERATIVE

2020-04-29 Thread Fabien COELHO
Hello Corey, Hello Peter, My 0.02 € about the alternative syntaxes: Peter: I think a syntax that would fit better within the existing framework would be something like WITH RECURSIVE t AS ( SELECT base case REPLACE ALL -- instead of UNION ALL SELECT recursive case ) A good

Re: Proposing WITH ITERATIVE

2020-04-29 Thread Corey Huinker
On Wed, Apr 29, 2020 at 10:34 AM Jonah H. Harris wrote: > On Wed, Apr 29, 2020 at 7:22 AM Peter Eisentraut < > peter.eisentr...@2ndquadrant.com> wrote: > >> Yeah the RECURSIVE vs ITERATIVE is a bit of a red herring here. As you >> say, the RECURSIVE keyword doesn't specify the processing but

Re: Proposing WITH ITERATIVE

2020-04-29 Thread Jonah H. Harris
On Wed, Apr 29, 2020 at 7:22 AM Peter Eisentraut < peter.eisentr...@2ndquadrant.com> wrote: > Yeah the RECURSIVE vs ITERATIVE is a bit of a red herring here. As you > say, the RECURSIVE keyword doesn't specify the processing but marks the > fact that the specification of the query is recursive.

Re: Proposing WITH ITERATIVE

2020-04-29 Thread Peter Eisentraut
On 2020-04-29 07:09, Fabien COELHO wrote: I'm wondering about how to use such a feature in the context of WITH query with several queries having different behaviors. Currently "WITH" introduces a named-query (like a view), "WITH RECURSIVE" introduces a mix of recursive and named queries, pg

Re: Proposing WITH ITERATIVE

2020-04-28 Thread Fabien COELHO
Hello Jonah, Nice. -- No ORDER/LIMIT is required with ITERATIVE as only a single tuple is present EXPLAIN ANALYZE WITH ITERATIVE fib_sum (iteration, previous_number, new_number) AS (SELECT 1, 0::numeric, 1::numeric UNION ALL SELECT (iteration + 1), new_number, (previous_number +

Re: Proposing WITH ITERATIVE

2020-04-28 Thread Jonah H. Harris
On Mon, Apr 27, 2020 at 8:50 PM Jeff Davis wrote: > Can you illustrate with some examples? I get that one is appending and > the other is modifying in-place, but how does this end up looking in > the query language? > To ensure credit is given to the original authors, the initial patch I'm

Re: Proposing WITH ITERATIVE

2020-04-28 Thread Jonah H. Harris
On Tue, Apr 28, 2020 at 11:51 AM Stephen Frost wrote: > Greetings Jonah! > Hey, Stephen. Hope you're doing well, man! > One of the first question that we need to ask though, imv anyway, is- do > the other databases use the WITH ITERATIVE syntax? How many of them? > Are there other

Re: Proposing WITH ITERATIVE

2020-04-28 Thread Jonah H. Harris
On Mon, Apr 27, 2020 at 8:50 PM Jeff Davis wrote: > Hi, > Hey, Jeff. Long time no talk. Good to see you're still on here. You might get better feedback in a month or so; right now we just got > into feature freeze. > Yep. No hurry. I've just been playing with this and wanted to start getting

Re: Proposing WITH ITERATIVE

2020-04-28 Thread Stephen Frost
Greetings Jonah! * Jonah H. Harris (jonah.har...@gmail.com) wrote: > On Tue, Apr 28, 2020 at 6:19 AM Andreas Karlsson wrote: > > > Do you have any examples of queries where it would help? It is pretty > > hard to say how much value some new syntax adds without seeing how it > > improves an

Re: Proposing WITH ITERATIVE

2020-04-28 Thread Jonah H. Harris
On Tue, Apr 28, 2020 at 6:19 AM Andreas Karlsson wrote: > Do you have any examples of queries where it would help? It is pretty > hard to say how much value some new syntax adds without seeing how it > improves an intended use case. > Hey, Andreas. Thanks for the response. I'm currently

Re: Proposing WITH ITERATIVE

2020-04-28 Thread Jonah H. Harris
On Tue, Apr 28, 2020 at 6:16 AM Oleksandr Shulgin < oleksandr.shul...@zalando.de> wrote: > will help the community to focus on the actual details of your proposal. > I'd like it if the community would focus on the details of the proposal as well :) -- Jonah H. Harris

Re: Proposing WITH ITERATIVE

2020-04-28 Thread Andreas Karlsson
On 4/27/20 6:52 PM, Jonah H. Harris wrote:> If there's any interest, I'll clean-up their patch and submit. Thoughts? Hi, Do you have any examples of queries where it would help? It is pretty hard to say how much value some new syntax adds without seeing how it improves an intended use case.

Re: Proposing WITH ITERATIVE

2020-04-28 Thread Oleksandr Shulgin
On Tue, Apr 28, 2020 at 5:49 AM Jonah H. Harris wrote: > On Mon, Apr 27, 2020 at 11:33 PM David Fetter wrote: > >> >> Have the authors agreed to make it available to the project under a >> compatible license? > > > If there’s interest, obviously. Otherwise I wouldn’t be asking. > > I said from

Re: Proposing WITH ITERATIVE

2020-04-27 Thread Jonah H. Harris
On Mon, Apr 27, 2020 at 11:33 PM David Fetter wrote: > > Have the authors agreed to make it available to the project under a > compatible license? If there’s interest, obviously. Otherwise I wouldn’t be asking. I said from the start why I wasn’t attaching a patch and that I was seeing

Re: Proposing WITH ITERATIVE

2020-04-27 Thread David Fetter
On Mon, Apr 27, 2020 at 10:44:04PM -0400, Jonah H. Harris wrote: > On Mon, Apr 27, 2020 at 10:32 PM David Fetter wrote: > > On Mon, Apr 27, 2020 at 12:52:48PM -0400, Jonah H. Harris wrote: > > > Hey, everyone. > > > > > If there's any interest, I'll clean-up their patch and submit. Thoughts? > >

Re: Proposing WITH ITERATIVE

2020-04-27 Thread Jonah H. Harris
On Mon, Apr 27, 2020 at 10:32 PM David Fetter wrote: > On Mon, Apr 27, 2020 at 12:52:48PM -0400, Jonah H. Harris wrote: > > Hey, everyone. > > > If there's any interest, I'll clean-up their patch and submit. Thoughts? > > Where's the current patch? It’s private. Hence, why I’m inquiring as to

Re: Proposing WITH ITERATIVE

2020-04-27 Thread David Fetter
On Mon, Apr 27, 2020 at 12:52:48PM -0400, Jonah H. Harris wrote: > Hey, everyone. > If there's any interest, I'll clean-up their patch and submit. Thoughts? Where's the current patch? Best, David. -- David Fetter http://fetter.org/ Phone: +1 415 235 3778 Remember to vote! Consider donating

Re: Proposing WITH ITERATIVE

2020-04-27 Thread Jeff Davis
Hi, You might get better feedback in a month or so; right now we just got into feature freeze. On Mon, 2020-04-27 at 12:52 -0400, Jonah H. Harris wrote: > In that it can reference a relation within its definition, this > iterative variant has similar capabilities as recursive CTEs. In > contrast

Proposing WITH ITERATIVE

2020-04-27 Thread Jonah H. Harris
Hey, everyone. It's been quite a while since I last contributed a patch but, as this is a new feature, I wanted to gather feedback before doing so. I've found this functionality, already in use at Universität Tübingen, to be both highly beneficial in many of my queries as well as a small change