-1

Let's say we have two tables: Customers(CustID, FirstName, OrderID) and Orders(ID, Date, Amount) and there is an indexed view join on CustID and ID and have a clustered index on these two columns.

so if I add a new record in Customers table, will the view gets executed first? so it will be like every time you modify any row in one of these two tables, the view needs to be executed, which is very tedious and not efficient .

closed as unclear what you're asking by Erik Darling, Marcello Miorelli, hot2use, Vérace, kevinsky Jun 26 at 12:29

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

2

That’s not actually how an indexes view works when it comes to the underlying tables having their data modified.

Views that have a clustered index are no longer just relying on the tables they reference to satisfy the query. They have data stored on disk as if they are a table and every time a row is added, changed or deleted from one of the underlying tables then the data in the view is also updated as part of that transaction. Explicit interaction with the view is not needed to sync the data in the view with its underlying tables.

Read this post that has more details

Not the answer you're looking for? Browse other questions tagged or ask your own question.