From: Richard Broersma <richard.broersma@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: sql pgsql <pgsql-sql@postgresql.org>
Subject: Re: Learning about WITH RECURSIVE
Date: Wed, 4 Nov 2009 14:27:14 -0800
Message-ID: <396486430911041427q3a0c9518v9c999a34290798ed@mail.gmail.com> (raw)
In-Reply-To: <27333.1257372664@sss.pgh.pa.us>
References: <396486430911041403u639c750bn488ada60822448c0@mail.gmail.com>
<27333.1257372664@sss.pgh.pa.us>
On Wed, Nov 4, 2009 at 2:11 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Richard Broersma <richard.broersma@gmail.com> writes:
>> Can anyone one explain why a "WITH RECURSIVE" query has the same
>> results regardless whether UNION or UNION ALL is specified?
>
> Well, if the rows are all different anyway, UNION isn't going to
> eliminate any ...
Actually I'm still confused. I must me missing something. When I
manually following the directions of:
http://www.postgresql.org/docs/8.4/interactive/queries-with.html
I get the following when I try:
WITH RECURSIVE t(n) AS (
VALUES (1)
UNION ALL
SELECT n+1 FROM t WHERE n < 100
)
SELECT sum(n) FROM t;
(1) --initial non-recursive working table
(1) UA (2) = (1,2) --new(1) working table
(1,2) UA (2,3) = (1,2,2,3) --new(2) working table
(1,2,2,3) UA (2,3,3,4) = (1,2,2,2,3,3,3,4) --new(3) working table
--
Regards,
Richard Broersma Jr.
Visit the Los Angeles PostgreSQL Users Group (LAPUG)
http://pugs.postgresql.org/lapug
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: richard.broersma@gmail.com, tgl@sss.pgh.pa.us
Subject: Re: Learning about WITH RECURSIVE
In-Reply-To: <396486430911041427q3a0c9518v9c999a34290798ed@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox