Re: How many views...

Поиск
Список
Период
Сортировка
От Greg Stark
Тема Re: How many views...
Дата
Msg-id 87sm6ttair.fsf@stark.xeocode.com
обсуждение исходный текст
Ответ на How many views...  ("Uwe C. Schroeder" <uwe@oss4u.com>)
Ответы Re: How many views...  ("Uwe C. Schroeder" <uwe@oss4u.com>)
Список pgsql-general
"Uwe C. Schroeder" <uwe@oss4u.com> writes:

> I could create a view for every node in the system which calculates the
> distance in the result set, making it easy to handle for the application:
> select * from <view> where distance <= 50
> The problem is, that the data will possibly contain thousands of nodes. I'd
> also need 2 or 3 views per node - which could lead to 50.000 or even 100.000
> views.

Normalize.

Make your view construct the distance for _every_ node. So your query looks
like:

  select * from <view> where node_id = 99 and distance <= 50

The danger here is you have to be absolutely sure that Postgres is pushing
that clause down into your view or the performance will be bad. But if your
view is at all sane then I think it will. And you'll certainly know if it
isn't.

--
greg

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

Предыдущее
От: Greg Stark
Дата:
Сообщение: Re: sequencing two tables
Следующее
От: "Uwe C. Schroeder"
Дата:
Сообщение: Re: How many views...