postgresql sticking "enable_seqscan=False" in a UDF sensible? I have a query which is taking 40 seconds to execute over the 80ms that it should if postgres where to filter off the primary key rather than doing a sequential scan. I have to force postgres to filter off the index by setting the above flag.

Having to stick this into the UDF seems like quite a hack to me, I mean it's unreasonable IMO that the query planner is chosing a seq scan over a indexed filter. Most of my SQL experience is off SQL Server, and I haven't experienced it missplaning such basic optimizations.

Edit:
To anyone interested, the query exeuction time droped from 80ms to 27 ms with 9.2, holly molley.
enable_seqscan=true doesn't do what you think it will.  It only allows the planner to choose that.  It doesn't force it.

Note it should be on generally anyway.  Sequential scans are far less costly in PostgreSQL than in MySQL since they scan in physical order.  There are many times when they are the cheaper plan.