I have been encountering poor performance in this Postgresql function.
This function is written as:
begin
return exists (select 1
from acs_permissions p, party_approved_member_map m, ...
end;
If I re-write it as:
begin
return 1 <= (select count(*)
from acs_permissions p, party_approved_member_map m, ...
...
end;
The original version can take *seconds* on my system. The latter version never takes over 100ms to run. This is with Postgresql 7.4.6. The timings are derived from Postgresql logging, i.e. enabling log_statement and log_duration. (FYI I have stats_row_level is enabled to support pg_autovacuum). This appears to be a Postgresql issue. I'm curious to know if anybody else can replicate my results and whether anybody is running with Postgresql 8.0.0 and if it gives the same results. I recall some notes about certain queries being slowed down a lot by stats_row_level, but I haven't gone back to check this out, and I really like using pg_autovacuum.
Comments? Ideas? Have I hit a true bug in Postgresql, or is it just poorly tuned?