pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Index + View Question
3+ messages / 3 participants
[nested] [flat]

* Index + View Question
@ 2006-11-03 19:17  Dylan Lorimer <edylan@google.com>
  0 siblings, 2 replies; 3+ messages in thread

From: Dylan Lorimer @ 2006-11-03 19:17 UTC (permalink / raw)
  To: pgsql-sql

Hi,

If I've got several tables, each with their own indexes. I also have a view
that aggregates several of these tables. My question is, as novice-like as
it may sound, do I need to create new indexes on the view or do the indexes
from the orig. tables apply somehow when I select data from the view?

Cheers,
Dylan

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Index + View Question
@ 2006-11-03 19:36  Andrew Sullivan <ajs@crankycanuck.ca>
  parent: Dylan Lorimer <edylan@google.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Andrew Sullivan @ 2006-11-03 19:36 UTC (permalink / raw)
  To: pgsql-sql

On Fri, Nov 03, 2006 at 11:17:30AM -0800, Dylan Lorimer wrote:
> If I've got several tables, each with their own indexes. I also have a view
> that aggregates several of these tables. My question is, as novice-like as
> it may sound, do I need to create new indexes on the view or do the indexes
> from the orig. tables apply somehow when I select data from the view?

You _can't_ create an index on the view.  Depending on what version
of PostgreSQL you are using, it will be more or less intelligent
about using the indexes in your views.  But keep in mind that there
are some cases where the indexes on several tables simply won't work
-- if the condition is such that all the tables need to be compared
to one another, for instant, no index will help you, because you'll
end up pulling everything into memory before anything else can
happen.

A

-- 
Andrew Sullivan  | ajs@crankycanuck.ca
When my information changes, I alter my conclusions.  What do you do sir?
		--attr. John Maynard Keynes



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Index + View Question
@ 2006-11-03 19:48  imad <immaad@gmail.com>
  parent: Dylan Lorimer <edylan@google.com>
  1 sibling, 0 replies; 3+ messages in thread

From: imad @ 2006-11-03 19:48 UTC (permalink / raw)
  To: Dylan Lorimer <edylan@google.com>; +Cc: pgsql-sql

When you select from views, you are infact selecting from the
underlying tables. Indexes created on those tables are used
ultimately.

--Imad
www.EnterpriseDB.com


On 11/4/06, Dylan Lorimer <edylan@google.com> wrote:
> Hi,
>
> If I've got several tables, each with their own indexes. I also have a view
> that aggregates several of these tables. My question is, as novice-like as
> it may sound, do I need to create new indexes on the view or do the indexes
> from the orig. tables apply somehow when I select data from the view?
>
> Cheers,
> Dylan
>



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2006-11-03 19:48 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-11-03 19:17 Index + View Question Dylan Lorimer <edylan@google.com>
2006-11-03 19:36 ` Andrew Sullivan <ajs@crankycanuck.ca>
2006-11-03 19:48 ` imad <immaad@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox