indexing - Can I force merge index in Mysql -
i have query looking
select fld table id > 50000 , fld_1 = 0 limit 1000
both id , fld_1 indexed. using either 1 of them better result? force index using 1 of them.
i referring - http://dev.mysql.com/doc/refman/5.1/en/index-merge-optimization.html#index-merge-intersection
i don't know of way force index-merge. conditions on manual page describe conditions when index-merge can done, , optimizer should automatically if can (and if cost-based optimizer decides it's worth so). can't force index-merge if it's not possible.
but compound index performs better index-merge anyway, better strategy.
the order of columns matters. put columns equality comparisons first in index, columns inequality comparisons.
create index idxfld1id on `table` (fld_1, id);
see presentation how design indexes, really.
you can make schema changes such creating indexes -- without downtime -- using http://www.percona.com/doc/percona-toolkit/pt-online-schema-change.html
of course, first try on test copy of database, learn how use tool.
Comments
Post a Comment