"Cox, Brian" <Brian(dot)Cox(at)ca(dot)com> writes:
> The following fails with a "stack depth limit exceeded":
> DELETE FROM some-table WHERE pk IN (pk1, pk2, ..., pkN)
> where pk = primary key and N is large, may be > 50000.
> Is there some limit as to the number of rows that can
> be deleted in a single DELETE?
Not as such, but there's a limit on the complexity of WHERE clauses.
Raising max_stack_depth might help you, but you'll run out of RAM
eventually.
(FWIW, 8.2 will cope a lot better with this particular construct.)
regards, tom lane