I wrote an [algorithm to determine natural keys on raw data][1], and the math behind [combinatorics][2] certainly comes into play for estimating performance. If I want to find all possible unique keys on a table of 25 columns, setting a max key size to 3 columns, there are C(25, 3) + C(25, 2) + C(25, 1) = 2625 possible keys ("C(25, 3)" means "out of 25 columns, pick 3"). If I allow my algorithm to search that table for a key of length up to 25 columns, there are over 33 million possibilities to query (no one would do that, but it's still good to know how much that would cost).
[1]: http://www.sqlservercentral.com/scripts/T-SQL/62086/
[2]: http://en.wikipedia.org/wiki/Combination
↧