For reporting purposes, I usually use a wide index across all the fields that are relevant to creating the reports. So, for example, my sales table has this type of data:
sale_id sale_date salesperson_id product_id referral_id [other sales data] sale_id is an auto_incrementing primary key. Most of the reports I run are date-based -- show me the sales for xxxx date, for yyyy salesperson, grouped by product_id and referral_id. My index for this table would be: (sale_date, salesperson_id, product_id, referral_id) My question is this: I know it's not good to index fields that have few unique values, but what about including a field like that in a wide index? If product_id only has 5 values, does it hurt to include it in this wide index? Would it be better to include it or leave it out, if I'm grouping by that field? Is there a rule of thumb for unique-ness when indexing? (i.e. a column should have X unique values before using it in an index...) Any insight is appreciated. Thanks, --jeff P.S. -- um, sql sql sql -- I can't believe how strict the filter for this list is... --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php