Re: Performance of a view

Поиск
Список
Период
Сортировка
От John McCawley
Тема Re: Performance of a view
Дата
Msg-id 437CAAEE.2010808@hardgeus.com
обсуждение исходный текст
Ответ на Re: Performance of a view  ("Thomas F. O'Connell" <tfo@sitening.com>)
Список pgsql-general
> I'd be curious to see what would happen if you added claimnum as a
> field in your view. I don't have a complete understanding of the
> postgres internals in terms of how it is able to push outer clauses
> down in to its views, but I think it might be able to optimize in
> that fashion if it is able to add a WHERE clause internally to the
> view, which it can't do in the case of claimnum since it doesn't
> exist in the view.


I added the claimnum and this actually slowed it down a bit because of
the additional group by, however I then changed my where clause to
filter on the view's claimnum rather than tbl_claim's claimnum, and I
got the results I wanted.

It seems to me that in the future I should always construct my views
such that my WHERE clauses end up on the view and not on any tables that
they join with.  The only problem with this is that very often I don't
know in advance what fields the client will want to search by, and now
I'll end up with two steps instead of one (modify my code AND modify the
view), however the speed increase is an order of magnatude and well
worth it.

Thanks!

John


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

Предыдущее
От: "codeWarrior"
Дата:
Сообщение: Re: Very slow queries on 8.1
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Very slow queries on 8.1