Re: "memory exhausted" in query parser/simplifier for many nested parentheses

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Niklas Hambüchen <mail(at)nh2(dot)me>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org, ruben(at)benaco(dot)com, Niklas Hambüchen <niklas(at)benaco(dot)com>
Subject: Re: "memory exhausted" in query parser/simplifier for many nested parentheses
Date: 2024-12-12 16:05:48
Message-ID: 654489.1734019548@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

=?UTF-8?Q?Niklas_Hamb=C3=BCchen?= <mail(at)nh2(dot)me> writes:
> we noticed that when writing a large query of form
> (((A OR B) OR C) OR ...)
> with many terms (e.g. 13000) this causes one of two errors:
> 1. memory exhausted at or near "("
> 2. stack depth limit exceeded
> ...
> We consider this a bug because it means one cannot easily generate large queries that query a couple thousand entries in a `SELECT ... WHERE` condition.

[ shrug... ] Even if these examples didn't fail, they would perform
terribly. Limits are a fact of life. Write your query some other
way, for example using "x IN (list)" or other shortcut syntaxes.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Niklas Hambüchen 2024-12-12 16:46:18 Re: "memory exhausted" in query parser/simplifier for many nested parentheses
Previous Message Mike Bayer 2024-12-12 15:59:49 Re: invalid constraint type "n" when using pg_catalog.pg_get_constraintdef() on pg17, regression from pg16