"Aaron Swartz" <me(at)aaronsw(dot)com> writes:
> We have the PL/Python function get_foo(n) that returns an array. If this
> function is declared IMMUTABLE, then:
> SELECT * FROM tablenamehere WHERE id = any(get_foo(21));
> returns quickly. If the function is declared STABLE, however, PostgreSQL
> seems to incorrectly run it for every row in the table and it takes forever.
= ANY isn't indexable in 8.1, so there's no obvious reason why either
version would be fast. You're going to have to provide more detail if
you want help. For starters, what does EXPLAIN ANALYZE show in each
case? What's the schema of the table (\d output will do)?
regards, tom lane