| From: | Richard Broersma <richard(dot)broersma(at)gmail(dot)com> |
|---|---|
| To: | sql pgsql <pgsql-sql(at)postgresql(dot)org> |
| Subject: | Learning about WITH RECURSIVE |
| Date: | 2009-11-04 22:03:33 |
| Message-ID: | 396486430911041403u639c750bn488ada60822448c0@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-sql |
Can anyone one explain why a "WITH RECURSIVE" query has the same
results regardless whether UNION or UNION ALL is specified?
broersr=> WITH RECURSIVE t(n) AS (
broersr(> VALUES (1)
broersr(> UNION
broersr(> SELECT n+1 FROM t WHERE n < 100
broersr(> )
broersr-> SELECT sum(n) FROM t;
sum
------
5050
(1 row)
broersr=> WITH RECURSIVE t(n) AS (
broersr(> VALUES (1)
broersr(> UNION ALL
broersr(> SELECT n+1 FROM t WHERE n < 100
broersr(> )
broersr-> SELECT sum(n) FROM t;
sum
------
5050
(1 row)
--
Regards,
Richard Broersma Jr.
Visit the Los Angeles PostgreSQL Users Group (LAPUG)
http://pugs.postgresql.org/lapug
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2009-11-04 22:11:04 | Re: Learning about WITH RECURSIVE |
| Previous Message | Bryce Nesbitt | 2009-11-04 21:00:32 | Mangled high bit characters with pg_server_prepare=0 in DBD::Pg |