Some additional thoughts: what appears to take the most time (i.e. account for the highest cost in the explain), is _not_ running the function itself (cost=0.00..0.01), but comparing the result from that function with the name1 column in the mappings table (cost=0.00..35935.05). Am I right? (See EXPLAIN in previous post.) If so: that's pretty strange, because the name1-column in the mappings table is indexed...
jan. ---------------------------(end of broadcast)--------------------------- TIP 3: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faq