Try to force a unique plan, like that:

SELECT field, field2 ...
FROM table1
WHERE field3 = 'xxx'
AND field4 = 'yyy'
AND field5 = 'zzz'

so, in that example, I need the planner to use my field4 index, but the planner insists to use the field5, so I rewrite the query like this:

SELECT field, field2 ...
FROM table1
WHERE trim(field3) = 'xxx'
AND field4 = 'yyy'
AND trim(field5) = 'zzz'

I  didn´t give any option to the planner, so I get what plan I want.

Waldomiro


Tom Lane escreveu:
"Michal J. Kubski" <michal.kubski@cdt.pl> writes:
  
[ function that creates a bunch of temporary tables and immediately
joins them ]
    

It'd probably be a good idea to insert an ANALYZE on the temp tables
after you fill them.  The way you've got this set up, there is no chance
of auto-analyze correcting that oversight for you, so the planner will
be planning the join "blind" without any stats.  Good results would only
come by pure luck.

			regards, tom lane