I have a small doubt on indexing for a column in a table. Already I have an index for a date column with the order ASC. Is it good to have another index with the order DESC? Will it work fine? Thanks in advance.
- In general, no. But that could depend on the database.Gordon Linoff– Gordon Linoff2018-06-29 01:55:34 +00:00Commented Jun 29, 2018 at 1:55
- @KenWhite I can do ORDER BY DESC for the particular column but already I have an index with ASC for the column so, I have quite confused whether this will give impact in my query performance. And one more thing for another process I have used the index with ASC. Now I need the same column to search with ORDER BY DESC.Bhuvanesh Waran– Bhuvanesh Waran2018-06-29 01:59:54 +00:00Commented Jun 29, 2018 at 1:59
Add a comment |
1 Answer
It will work, but there is no benefit at all to doing so. An index can be read in both directions, so it does not help you at all. Every index has costs, both in hard drive space and the processing power and time it takes to keep it up to date when adding/changing records, so adding indexes that are not needed is actually a disadvantage.