Re: How many views...

From: Greg Stark <gsstark(at)mit(dot)edu>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: How many views...
Date: 2004-11-29 06:49:32
Message-ID: 87sm6ttair.fsf@stark.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Uwe C. Schroeder" <uwe(at)oss4u(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Peter Eisentraut 2004-11-29 07:06:29 Re: [GENERAL] Adding Reply-To: <listname> to Lists configuration ...
Previous Message Greg Stark 2004-11-29 06:46:50 Re: sequencing two tables