Re: max_expr_depth - Mailing list pgsql-general

From Tom Lane
Subject Re: max_expr_depth
Date
Msg-id 9498.992914721@sss.pgh.pa.us
Whole thread Raw
In response to max_expr_depth  (Joseph Shraibman <jks@selectacast.net>)
List pgsql-general
Joseph Shraibman <jks@selectacast.net> writes:
> I recently tried to do a big update with postgres 7.1.2.  The update was
> something like
> UPDATE table SET status = 2 WHERE id IN (a few thousand entries)  AND
> status = 1;
> and I got:
> ERROR:  Expression too complex: nesting depth exceeds max_expr_depth =
> 10000

How many is "a few thousand"?  About 10000 by any chance?  That
"IN (a, b, ...)" will expand to "((id = a) OR (id = b) OR ...)"
which would set off the expression-too-complex detector right about
10000 ORs, if I'm not mistaken.

You could crank up the max_expr_depth SET variable if you are so
inclined, but frankly performance of this query is going to suck
anyway.  I'd recommend sticking the target id values into a temp
table that you can join against, instead.

As for why we have an expression-too-complex check, it's because
mysql's crashme test used to provoke a stack overflow crash...

            regards, tom lane

pgsql-general by date:

Previous
From: "Dave Cramer"
Date:
Subject: Error: RelationBuildTriggers: 2 record(s) not found for rel customerinfo
Next
From: Joseph Shraibman
Date:
Subject: Re: max_expr_depth