Sunday, February 19, 2012

Indexed Views Vs temp tables

With my understanding of indexed views and according to books I read
"indexed views" are supposed to perform much better than "temp tables"
(temp table having primary key and indexed view with clustered index
on the same keys).

But when I tried in my system I am getting opposite results. With
Indexed Views it takes 3 times more time.

Any body has any reasons for that? Or my understanding was wrong?

thanks
Raghu AvirneniIndexed views are expensive when adding data, since adding to the base table
also has to update the view's indexes as well as the base table.

It only helps on the retrieve (and only if the index on the view is used in
the query plan).

I have only used them for lookup tables that rarely change.

"Avirneni" <ravirneni@.trafficmp.com> wrote in message
news:15a48475.0410061606.24dd220d@.posting.google.c om...
> With my understanding of indexed views and according to books I read
> "indexed views" are supposed to perform much better than "temp tables"
> (temp table having primary key and indexed view with clustered index
> on the same keys).
> But when I tried in my system I am getting opposite results. With
> Indexed Views it takes 3 times more time.
> Any body has any reasons for that? Or my understanding was wrong?
>
> thanks
> Raghu Avirneni|||Temp tables and views are different animals. Like David mentioned, examine
the query plan to ensure the index on the view is actually being used.

--
Hope this helps.

Dan Guzman
SQL Server MVP

"Avirneni" <ravirneni@.trafficmp.com> wrote in message
news:15a48475.0410061606.24dd220d@.posting.google.c om...
> With my understanding of indexed views and according to books I read
> "indexed views" are supposed to perform much better than "temp tables"
> (temp table having primary key and indexed view with clustered index
> on the same keys).
> But when I tried in my system I am getting opposite results. With
> Indexed Views it takes 3 times more time.
> Any body has any reasons for that? Or my understanding was wrong?
>
> thanks
> Raghu Avirneni

No comments:

Post a Comment