Jeff makes an excellent point - to clarify, PG/plSQL functions are compiled when first encountered by a backend and are NOT recompiled if you ANALYZE.
So to make sure that all function calls make use of the data gathered by ANALYZE you need to restart AOLserver in order to flush backend connections. On restart, as each pool handle starts up a backend connection, the first call to each function will generate a new execution plan.
The other alternative is to do a CREATE OR REPLACE of critical functions in order to force a recompile but in practice restarting AOLserver's easier.
This would only explain your problem if your OpenACS instance has been running without interruption for a fairly long time and if your installation has grown.
The underlying issue is that a good plan for tables which are nearly empty may be a very bad plan for tables which have lots of data ...