Re: [PROPOSAL] Max recursion depth in WITH Queries (Common Table Expressions)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Valery Popov <v(dot)popov(at)postgrespro(dot)ru>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [PROPOSAL] Max recursion depth in WITH Queries (Common Table Expressions)
Date: 2015-10-28 15:07:34
Message-ID: 21358.1446044854@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Valery Popov <v(dot)popov(at)postgrespro(dot)ru> writes:
> 28.10.2015 16:33, Tom Lane :
>> The standard way of dealing with that is to include logic in the query to
>> limit the recursion depth, for example ...

> Yes, I agree with this thesis. But I think in some cases would be
> better to receive error message and stop execution than results will
> incomplete.

Sure, but you can do that at the SQL level if you have a mind to, as well.

In practice, I think people tend to use recursive queries mainly for data
layouts where the maximum recursion depth isn't terribly clear, so that
setting this GUC to a useful value would be a difficult task anyway.
If you end up setting it to 100X or 1000X more than you think your queries
could possibly recurse, you might as well use some other approach like
statement_timeout, which has got a closer relationship to what you care
about, ie how long you want to wait.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2015-10-28 15:42:28 Re: Add EXTRA_CFLAGS to configure
Previous Message Valery Popov 2015-10-28 14:58:22 Re: [PROPOSAL] Max recursion depth in WITH Queries (Common Table Expressions)