Quote:
|
Originally Posted by Pat Phelan
Sorry poots, I'm with blindman on this. I'd rather be able to use an index on the company id in a very small table then join using index seeks on a highly selective surrogate key than to do the table scans you are advocating. If you build your queries correctly, you could use the clustered index you suggested which would allow you to at least do an index scan instead of a table scan and that could be nearly as efficient as using the surrogate keys.
-PatP
|
I'm advocating
avoiding scans.
I'll whip up some code, mebbe at the weekend - busy week. I'd like to bottom this one out since this is a default design decision I make for this sort of database.
To be clear - I am advocating this sort of physical design in the specific circumstance where a single database is designed to store distinct and discrete data sets in the same domain. These datasets are never to be treated as one, always separately. In fact, if the data of two of these sets were to get retrieved together it would indicate either an error or a security breach.
I am not preaching a one-size-fits-all dogma which is the de facto position of most people on the surrogate-natural key divide.
The last two databases I released were of this nature (one a survey database, the other hosting multiple clients' data). Using this design even complex queries are jam packed full of seeks and merge joins. No lookups, scans, hash joins. Absolutely zero superfluous logical reads.
I don't see how it isn't obvious - all "like" data is clustered with all related data. It is essentially logically & physically partitioned. Why on earth would you want to stuff a page full of 20 different clients' data when a client should only ever access their own data?