Question

i have a date dimension table with a char(7) field called year_month_number with an index on it as follows:

ALTER TABLE `dim_date` add INDEX `year_month_number` (`year_month_number` ASC);

it has data in it like '2013-06' or '2013-07'.

im having performance issues, so did an explain,

'1', 'SIMPLE', 'effective_date', 'ref', 'PRIMARY,year_month_number', 'year_month_number', '22', 'const', '29', 'Using where'

it seems like the key_len = 22, can anyone explain why it is not 7 (as suggested in this post)? i have tried dropping and recreating the index,

Était-ce utile?

La solution

not sure why it shows 22, maybe some encoding issue - is it char(7) binary?

anyway - change field to usual int, where you will store YYYYMM as number, this will be only 4 bytes

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top