HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

Preordering the table by a specified column

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
thecolumnpreorderingtablespecified

Problem

I have a table and I am always getting the data by ordering a column. In my case, I order by datenum. However, the selection is so slow because of the ordering.

Is it possible to order the table after datenum. This column is defined as unique. If defined as an index, would the selection will be faster?

Solution


  • There is no natural, implied or intrinsic ordering to a table



  • Any order is only guaranteed by the outermost ORDER BY



If this is slow, then you can either

  • make the index covering (a UNIQUE constraint is an index already)



  • make it the clustered index (which is covering by its nature)

Context

StackExchange Database Administrators Q#5160, answer score: 5

Revisions (0)

No revisions yet.