Re: Index on View ?

Keith Gray <keith@heart.com.au>

From: Keith Gray <keith@heart.com.au>
To: Richard Huxton <dev@archonet.com>
Cc: PostgreSQL <pgsql-sql@postgresql.org>
Date: 2001-04-05T23:14:59Z
Lists: pgsql-sql
Richard Huxton wrote:
> 
> Indexes on underlying tables should be used though. Difficult to suggest
> what indices you might need without knowing the view/tables/queries
> involved.

As an example I may have an "Invoice" table with several thousand invoices.
I could design a query/view "Aged" to get all unpaid invoices 
greater than 15 days old.

I would often look for Invoices per Client and should have an index on 
Invoice(ClientID).

	e.g. CREATE INDEX Invoice_ClientID ON Invoice(ClientID);


Is there any advantage in having an index on ClientID for the Aged query?

	e.g. CREATE INDEX Aged_ClientID ON Aged(ClientID);

Would this index be continually maintained by the RDBMS or only on lookup?




Keith