I have two tables that are around 500k rows each (and growing). Inserts/Updates happen to these constantly, sometimes 100’s per minute. The system is having performance issues, namely timeouts, on basic inserts into these tables. We’ve tuned our indexes, and done the usual optimizations. But I’m wondering if the fact that these two tables are referenced in 5 views with heavy joining might be detrimental. I always thought, maybe mistakenly, that as underlying tables change, the views that reference them change too. So if the tables are changing that much, maybe our system is getting overwhelmed by having to constantly play catch-up updating views.
I have two tables that are around 500k rows each (and growing). Inserts/Updates happen
Share
Unless they’re indexed views (you haven’t mention such in your question), they’re not “updated” at all.
Normal views are similar to a macro in C – they’re just a convenient shorthand to hide a part of a larger expression. They’re expanded out into the parse tree of whatever statement references them, and the entire tree is then compiled and optimized – at the point of usage.
For indexed views, you would be largely correct – the views are maintained as part of the same transaction that performs changes in the base tables. However, the rules for indexed views have been designed so that this update activity shouldn’t incur too large a penalty (they can be maintained without having to re-query the entire base table).