Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Index View or Table?
Message
De
10/03/2016 16:13:05
 
 
À
10/03/2016 06:46:41
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Indexation
Versions des environnements
SQL Server:
SQL Server 2008 R2
Divers
Thread ID:
01632781
Message ID:
01632812
Vues:
31
>Hi,
>
>a system I have has a table called Transactions, then a view based on that called viewTransactions and then another view based on the first view called viewTopTransactions.
>
>Should I create indexes on the underlying table and that will speed up queries against the views? Or should I create indexes on the views? or should I index both table and views?
>
>The queries are like this:
>
>SELECT DISTINCT [PNRStatus] FROM [viewTransactions] ORDER BY [PNRStatus]

HI, Frank - you can create materialized indexes from views. I have an online article that talks about an example:

http://www.codemag.com/Article/1601051 (the first of the thirteen items). Go to the section called "Answer 1: Knowing the Differences Between Materialized Views and Standard Views"

One thing I would definitely avoid (as Naomi said) is creating views off of views. Once someone does that, it usually paves the way for views off views off views. These can impact performance and can be difficult to maintain.

When you say you want to view Top Transactions, what would the "top" be based on?

Also, can you post the structure of the Transactions table?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform