473,486 Members | 2,427 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Updating indexed views - who pays?

This from a SQL Server manual:

"Complex queries, however, such as those in decision support systems,
can reference large numbers of rows in base tables and aggregate large
amounts of information into relatively concise aggregates (such as sums
or averages). SQL Server 2000 supports creating a clustered index on a
view that implements such a complex
query. When the CREATE INDEX statement is executed, the result set of
the view SELECT is stored permanently in the database. Future SQL
statements that reference the view will have substantially better
response times. Modifications to the base data are automatically
reflected in the view."

My question arises from the last sentence. At what point are the views
updated with the new data? If I am running a transaction that updates
some dependent tables, is there a performance impact while the indexed
views are updated?

Jess Askin.

Jul 23 '05 #1
3 2426
This is a qustion for Kalen, since she does internals. But I seem to
remember that the indexes will be re-built on the first invocation of
the VIEW after the base tables have changed, and not while the base
tables are being changed.

Jul 23 '05 #2
An indexed view is updated within the transaction that modifies the
relevant base table(s). In other words, the indexed view is updated
immediately.

So yes, the performance of inserts/updates/deletes will be influenced.
If it is a narrow view (few columns with few bytes), then the
performance hit would be comparable with the addition of a 'regular'
index to the base table.

HTH,
Gert-Jan
te********@hotmail.com wrote:

This from a SQL Server manual:

"Complex queries, however, such as those in decision support systems,
can reference large numbers of rows in base tables and aggregate large
amounts of information into relatively concise aggregates (such as sums
or averages). SQL Server 2000 supports creating a clustered index on a
view that implements such a complex
query. When the CREATE INDEX statement is executed, the result set of
the view SELECT is stored permanently in the database. Future SQL
statements that reference the view will have substantially better
response times. Modifications to the base data are automatically
reflected in the view."

My question arises from the last sentence. At what point are the views
updated with the new data? If I am running a transaction that updates
some dependent tables, is there a performance impact while the indexed
views are updated?

Jess Askin.

Jul 23 '05 #3
On 19 May 2005 09:17:02 -0700, --CELKO-- wrote:
This is a qustion for Kalen, since she does internals. But I seem to
remember that the indexes will be re-built on the first invocation of
the VIEW after the base tables have changed, and not while the base
tables are being changed.


Hi Joe,

You remember wrong. The indexed view is updated at each modification to
the base table(s).

However, the view is not completely re-executed (that would be a major
performance killer!). Instead, SQL Server uses some nifty logic to speed
up the update to the view. For example, if the view has a SUM(...) and a
COUNT(...) column, then the "new" values are computed by adding the SUM
and COUNT of the new rows and subtracting the SUM and COUNT of the old
roms from the "old" values in the indexed view.

With this in mind, you'll suddenly have a lot better understanding for
the list of limitations imposed on indexed views :-)
To the OP: there is a performance impact on modifications to the base
table, but it will be a small impact in most cases. You'll have to test
each specific case to be sure, though!

Best, Hugo
--

(Remove _NO_ and _SPAM_ to get my e-mail address)
Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
4209
by: Vincent LIDOU | last post by:
Do not trust values returned by materialized views under SQL Server without frequently checking underlying tables!!! I already posted this message under microsoft.public.sqlserver.server and I'm...
1
10106
by: Ariel | last post by:
Hi, I have a problem, maybe someone can help me. I'm traing to create a view with a Linked Server This query works great: select id, descr from SERVER.DB.dbo.TABLE When I tray to create...
2
7323
by: Avirneni | last post by:
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...
3
1799
by: noelwatson | last post by:
I am looking to create a constraint on a table that allows multiple nulls but all non-nulls must be unique. I found the following script http://www.windowsitpro.com/Files/09/21293/Listing_01.txt...
224
6632
by: VB6 User | last post by:
Hi all devies! Many (.NUT, .NOT or whatever), APIs, VB6, Views & Questions Your can not call APIs directly in .NET, only via P/Invoke. There are some things that cannot be done in...
0
1210
by: tone | last post by:
i have just changed a field so that it automatically grabs x/y coord for a site from an arcmap doc. problem is that as it does this it creates a new record for each site instead of updating the...
1
3897
by: Mr,Goody | last post by:
hi frends. i have such a great problem.i want to use union in indexed view and i must have to use it. because i cant make a one table because in those two tables there are 2,000,000 records...
1
1628
by: Jason Wilson | last post by:
I was looking to improve the performance of an ASP.NET application by creating the an indexed view that could be used instead of some of the root tables. What I didn't realize is that it would...
17
2748
by: David C. Ullrich | last post by:
Having a hard time phrasing this in the form of a question... The other day I saw a thread where someone asked about overrideable properties and nobody offered the advice that properties are...
0
7100
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7126
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6842
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7330
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5434
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4559
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3070
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
598
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
262
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.