mysql - I've indexed a combined column, should I index separate column too? -
i have table this
create table `tbl` ( `id` int(10) unsigned not null, `pid` int(10) unsigned not null, `cid` int(10) unsigned not null, `name` int(11) default null, `desc` varchar(500), `deleted` tinyint(1) unsigned not null default 0, `createdat` datetime default null, primary key `pid_cid` (`pid`,`cid`) ) engine=innodb
where
clause of select queries those:
where pid=pid [and deleted = 1]; cid=cid [and deleted = 1]; pid=pid , cid=cid [and deleted = 1];
- should index
pid
,cid
separately? - should index
deleted
?
the optimal set of indexes be:
pid, deleted
cid, deleted
pid, cid, deleted
whether need 3 depends on data. how many different deleted values there each pid
/cid
. first 2 may sufficient.
indexing deleted
not useful. presumably, takes on 2 values, not candidate index.
Comments
Post a Comment