Jim C. Nasby írta:

Those queries aren't the same though. The view is equivalent to

SELECT *
FROM
   (select 'AAA' AS prefix,id from table 1
       union select 'AAA',id from table 2
   ) view
WHERE prefix||id = '...'

In this case the prefixes have already been unioned together, so there's
no chance for the planner to use the function index.

If break the WHERE clause into seperate clauses, such as

WHERE prefix='AAA' AND id = '2005000001'

then I think the planner will know what selects it can simply ignore. If
that doesn't work, then add 'AAA'||id AS fullid to each of the selects
in the view and that should allow the function indexes to be used.

Thanks, both method sworks very fast now and use the expression indexes.
Thanks for the patience and the explanations.

Best regards,
Zoltán Böszörményi


---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
      subscribe-nomail command to [EMAIL PROTECTED] so that your
      message can get through to the mailing list cleanly

Reply via email to