473,748 Members | 7,118 Online
Bytes | Software Development & Data Engineering Community
+ 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 2441
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********@hotm ail.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
4225
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 amazed nobody from Microsoft answered about this problem. By inserting lots of data into our two main tables for about 30 minutes, we can fail our materialized view that performs a count_big on those two tables. Executing (after of course...
1
10131
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 the view:
2
7349
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 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?
3
1812
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 that works fine, but the following line CREATE UNIQUE CLUSTERED INDEX idx1 ON v_multinulls(a)
224
6839
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 .NET, and that requires APIs. Earlier people
0
1227
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 existing record for each site. within the site table there is an indexed autonumber field but the site name field is not indexed, so cannot prevent duplication within site field, hence the problem Any ideas out there?,
1
3920
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 entered daily.So please give me suggestion. can also give me alternate of using UNION in indexed view.and i want to use idexed view only because i will do searching afterwards. Regards, Mr.Mirza
1
1640
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 affect any future conenctions to the root tables. This of course crashed the application on any type of insert, update, or delte from the root tables.
17
2784
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 Bad. So maybe we've got over that. I suppose properties could have Bad consequences if a user doesn't know they exist and think that a certain property of an object is just an ordinary attribute. But that applies to
0
9530
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9363
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9238
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8237
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6073
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4593
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4864
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2775
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2206
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.