Linked Questions
21 questions linked to/from SQL Server indexes - ascending or descending, what difference does it make?
3 votes
1 answer
229 views
What approach is usually used for indexing, Is it ascending or descending? [duplicate]
I was applying indexing to a fresh database(no records on most of the tables) What approach should I use apart from considering filter criteria. Should I index records in descending order since any ...
279 votes
6 answers
172k views
How important is the order of columns in indexes?
I've heard that you should put columns that will be the most selective at the beginning of the index declaration. Example: CREATE NONCLUSTERED INDEX MyINDX on Table1 ( MostSelective, ...
16 votes
10 answers
15k views
Order by desc as default option for SQL Server Management Studio?
Is there some way to make SQL Server Management Studio return rows descending by default ? Every time i open a table via the menu (for instance by selecting return all rows), i get the oldest rows at ...
38 votes
2 answers
31k views
Primary key Ascending vs Descending
In Sql Server, I have a table with an Identity primary key. Often I want the latest few new records, so I grab the Top n sorted by descending the primary key. Should I define the Primary Key index as ...
6 votes
1 answer
8k views
Optimizing indices for ranking in SQL Server
We've got a wide table that we're currently trying to optimize. The table has 50 columns (stats) that we eventually want to rank in descending order. Currently there's well over 5 million rows. We're ...
7 votes
5 answers
4k views
Descending sort order indexes
The Database Engine Tuning Advisor has finally given up the ghost and can't help me any more, so I'm having to learn a little bit more about indexes (shouldn't it be indices?). I think I'm more or ...
4 votes
4 answers
6k views
Does order of indexing (ascending vs descending) matter?
Some said for compound indexes then ordering matter. Some says ordering doesn't matter. Which one is right? And why? I mean if I look up phone, I don't see how whether the phone is sorted a to z or ...
5 votes
4 answers
2k views
Clustered index default sorting order
I’m creating a table with a primary key clustered index. When I’m creating without asc/desc, what is the default sorting order? Which sorting order (ASC or DESC) is more efficient? Here is the sample ...
2 votes
5 answers
2k views
MS SQL: Performance for querying ID descending
This question relates to a table in Microsoft SQL Server which is usually queried with ORDER BY Id DESC. Would there be a performance benefit from setting the primary key to PRIMARY KEY CLUSTERED (Id ...
1 vote
3 answers
2k views
SQL Server insertion performance
Let's suppose I have the following table with a clustered index on a column (say, a) CREATE TABLE Tmp ( a int, constraint pk_a primary key clustered (a) ) Then, let's assume that I have two ...
4 votes
0 answers
3k views
Ascending or descending index in MySql [duplicate]
This Q is about MySql - to read about ascending or descending indexes in MS SQL you can look here: SQL Server indexes - ascending or descending, what difference does it make? It refers to a different ...
5 votes
2 answers
565 views
Does clustered index sort order have impact on performance
If a PK of a table is a standard auto-increment int (Id) and the retrieved and updated records are almost always the ones closer to the max Id will it make any difference performance-wise whether the ...
1 vote
1 answer
1k views
Clustered Index Descending for Paging
I have a screen where i show all the latest posts and when the user click the read more link, i bring the next set based on Post Id(where id < latest one already shown). I have a clustered index ...
3 votes
2 answers
706 views
How to improve the performance of a SQL Server Select query?
The following T-SQL query is taking 54 seconds to execute: SELECT top (3) a.c1, b.c2, c.c3, d.c4 FROM table1 as a WITH (NOLOCK) JOIN table2 as b WITH (NOLOCK) ON a.c1 = b.c4 LEFT JOIN ...
0 votes
3 answers
508 views
C# linq optimization OrderByDescending()
I am using .OrderByDescending(x => x.Id) to return the most recent data in paged sets of 20 from a large dataset to a web application. I have been attempting to optimize the speed of my query and ...