Re: How many views... - Mailing list pgsql-general

From Greg Stark
Subject Re: How many views...
Date
Msg-id 87sm6ttair.fsf@stark.xeocode.com
Whole thread Raw
In response to How many views...  ("Uwe C. Schroeder" <uwe@oss4u.com>)
Responses Re: How many views...
List 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 by date:

Previous
From: Greg Stark
Date:
Subject: Re: sequencing two tables
Next
From: "Uwe C. Schroeder"
Date:
Subject: Re: How many views...