Re: Views don't seem to use indexes?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Views don't seem to use indexes?
Дата
Msg-id 309712.1635401752@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Views don't seem to use indexes?  (Tim Slechta <trslechta@gmail.com>)
Ответы Re: Views don't seem to use indexes?  (Tim Slechta <trslechta@gmail.com>)
Список pgsql-performance
Tim Slechta <trslechta@gmail.com> writes:
> Why does the planner not use an index when a view is involved?

It's not about a "view" ... you'd get the same results if you wrote
out the UNION ALL construct in-line as a sub-select.

I think you may be shooting yourself in the foot by not making sure that
the UNION ALL arms match in data type.  You did not show us the definition
of pworkspaceobject, but if pworkspaceobject.pobject_name isn't of type
text (maybe it's varchar?) then the type mismatch would prevent pushing
down a condition on that column.  The source code says:

 * For subqueries using UNION/UNION ALL/INTERSECT/INTERSECT ALL, we can
 * push quals into each component query, but the quals can only reference
 * subquery columns that suffer no type coercions in the set operation.
 * Otherwise there are possible semantic gotchas.

I'm too tired to reconstruct an example of the semantic issues...

            regards, tom lane



В списке pgsql-performance по дате отправления:

Предыдущее
От: "David G. Johnston"
Дата:
Сообщение: Re: Views don't seem to use indexes?
Следующее
От: Tim Slechta
Дата:
Сообщение: Re: Views don't seem to use indexes?