Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Would index tag speed up this SQL Select
Message
De
18/06/2015 08:50:44
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Indexation
Versions des environnements
SQL Server:
SQL Server 2014
Application:
Web
Divers
Thread ID:
01621119
Message ID:
01621120
Vues:
56
>I have the following SQL Select that looks for the last order number:
>
>select top 1 order_no from order_file where REC_ID <> 'D' order by order_no desc
>
>
>The column ORDER_NO is the Primary key and Identity. But I noticed in SSMS that this column does not have an Index. Do I need to create an index for this column or the fact that it is Primary key already created an index?
>
>Also, would creating an index on column REC_ID speed up the above SQL Select?

Create a compound index on REC_ID with included field Order_No.

Then, put that select in a query window and show the execution plan. It should use this index.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform