3 ms·
Ditto for tables where you need a significant part of the data, e.g. 25%. If all queries need that amount of data, an index is just a waste. If the tables are
by silvestrov 14y ago
Ditto for tables where you need a significant part of the data, e.g. 25%. If all queries need that amount of data, an index is just a waste.
If the tables are only queried once in a blue moon but written to very often (e.g. events/history/logs) then indexes can be wasteful.
- btilly 14y agoThe definition of "significant part" is highly hardware dependent. Several years ago the cutoff point was generally somewhere in the 5-10% range, but I'm sure that has changed. Also if you're creating indexes, the most powerful underutilized ability is to create concatenated indexes. Index 2 or 3 fields in one index. Those indexes can be used if you are querying the first field only, or the first 2, or the first 3. (Some databases will use them if you are querying the second, but that is much, much less efficient to do.) If you're looking things up by 2 fields sometimes, a concatenated index can really save time, and they are nearly as good as an index on a single field for queries that only need one field.