From: | Merlin Moncure <mmoncure(at)gmail(dot)com> |
---|---|
To: | Stefan Keller <sfkeller(at)gmail(dot)com> |
Cc: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Indexes not allowed on (read-only) views: Why? |
Date: | 2011-09-16 21:48:47 |
Message-ID: | CAHyXU0xD6Phx5o04n2Q9uK-VdsbRMHNeHGg-20TFp4LTgV2WbA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Fri, Sep 16, 2011 at 4:47 PM, Stefan Keller <sfkeller(at)gmail(dot)com> wrote:
> A (read-only) view should behave like a table, right?
>
>> CREATE INDEX t1_idx ON t1 (rem);
> ERROR: »v1« not a table
> SQL state: 42809
>
> => Why should'nt it be possible to create indexes on views in PG?
>
> An index on a view can speed up access to the tuples underlying. And
> "indexed views" could be a method of storing the result set of the
> view in the database, thereby reducing the overhead of dynamically
> building the result set. An "indexed view" should automatically adapt
> modifications made to the data in the base tables. So, there is some
> overhead here, but this is ok when speed in retrieving results
> outweighs the cost...
>
> And there is no practical reason since SQL Server can do it! See
> "Creating Indexes on Views"
> http://msdn.microsoft.com/en-us/library/aa933124%28v=sql.80%29.aspx
implementation across databases is different. in postgres, views are
essentially macros, thus there is no data to index.
merlin
From | Date | Subject | |
---|---|---|---|
Next Message | Rich Shepard | 2011-09-16 22:14:50 | Re: Apparent Problem With NULL in Restoring pg_dump |
Previous Message | Stefan Keller | 2011-09-16 21:47:02 | Indexes not allowed on (read-only) views: Why? |