Every once in a while, one needs a check. This is such a time.
I have tables that are used for reporting. They are deleted/inserted once a day or multiple times a day to "refresh the data" from the source always using a continuous date range (like month-to-date or a rolling 45 days). The source data has no ID or uniqueness to them.
The convention so far has been to use a clustered index on the date - every table has a date and every query uses a date (99% of the time). If the table has a column(s) that makes it unique, I have added those to the clustered to make it unique (e.g., status and email). If not, I have added an ID IDENTITY to make it unique.
Research seems to advise "use an incrementing ID" with few deviations. However, performance using this convention has been excellent - unless I am missing something somewhere.
So while this has been good, sometimes a peer check can be a good thing :)
- Any issues with date as the leading column in a clustered index (considering the above)?
- Is adding MY OWN ID Identity column for uniqueness better than MS SQL doing it for me?
- Would adding ID first, then date be better?
Environment: Azure SQL