On Jun 26, Chris Wilson modulated: > ... > In your case, the equivalent hack would be to compile the small > dimension tables into big CASE statements I suppose... > > > Nice idea! I tried this but unfortunately it made the query 16 seconds > slower (up to 22 seconds) instead of faster. Other possible rewrites to try instead of joins: -- replace the case statement with a scalar subquery -- replace the case statement with a stored procedure wrapping that scalar subquery and declare the procedure as STABLE or even IMMUTABLE These are shots in the dark, but seem easy enough to experiment with and might behave differently if the query planner realizes it can cache results for repeated use of the same ~100 input values. Karl -- Sent via pgsql-performance mailing list (pgsql-performance@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance