8
When I’m going to create an index no clustered in SQL SERVER, appears in SSMS the option to choose if the option "Columns" is ASC
or DESC
, as shown below:
It is usually used ASC
or DESC
for sorting the table results, but in the case of the index clustered I don’t quite understand the meaning.
I’d like to know the following:
- What’s the difference between
ASC
andDESC
in the case of the definition of an index clustered? - Define
ASC
orDESC
results in some noticeable difference in performance or other? - When should I use one and the other? In case, I can create an index clustered
ASC
and anotherDESC
for the same column?
I believe that to start with the normal table (asc) or "upside-down" (desc) depending on whether to have a standard query for example, which are usually in the first records, or last... (accompanying) +1
– rbz
@Rbz means that if I put
ORDER BY coluna_com_o_indice_clusterizado_com_DESC
then the results will beDESC
, even though I haven’t defined it inORDER BY
?– Wallace Maxters
No. For example: You have the "never stop" of the toll. It has a code referring to your sign. Imagine how fast the system has to be to make the query and release you while you pass the 40 km/h there right!?... So that’s where the index comes in, roughly, an internal BD consultation assistant. I even know that you already know everything. So let’s assume you’re traveling, so there in the "Never Stop" comic, you’d be at the end of the "Release Queries" table. Let’s assume that their system is intelligent, and always consult this table when you pass for a release. [...]
– rbz
[...] Even if your table has indexes, it can "start reading" from beginning to end (asc), or from end to beginning (desc), as if you were selecting and reading the results. You make a select and know that what you seek is usually at the end, so use (desc) to "start" your reading... basically this.
– rbz
The idea is that: even with indexes, it follows a sequence. It is better to start at the beginning or at the end!? ... as I only talked 1x about it, a long time ago, so I’m not sure, so I thought it best to comment only.
– rbz