"Dan Langille" <dan(at)langille(dot)org> writes:
> So I tried this:
> DELETE FROM clp
> WHERE NOT EXISTS (
> SELECT *
> FROM clp
> ORDER BY commit_date
> LIMIT 100);
> Uhh uhh, nothing deleted. I don't understand why.
Because the inner SELECT is a constant: you forgot to make it depend on
the current outer row. So EXISTS succeeds at every row, unless clp is
already empty.
regards, tom lane