Michael McCarthy <michael@tcsi.com> writes:
> I have traced the backend server in a debugger; a stack trace is attached
> below. What I see in examining the code is a recursive normalization of
> the query; postgres is running out of memory trying to convert the OR'ed
> ANDs query to conjunctive normal form (CNF).
Yes, the CNF-conversion code is pretty awful. I have reduced its
badness somewhat in current sources, but really we need to rethink the
whole problem --- for queries that are naturally expressed as
OR-of-ANDs, forcing the condition into AND-of-ORs is a loser.
You could try folding prepqual.c from current sources (get the nightly
snapshot or use CVS) into 6.5. I'm not sure it would merge cleanly,
but it'd beat reinventing the fixes I made.
regards, tom lane