in reply to Re: Re: How to count rows using DBI & mysql - Performance results
in thread How to count rows using DBI & mysql - Performance results
hding is right. In that case, declare a multicolumn unique index. That does precisely what you are asking for. MySQL will look at the first column first, so it should be the more unique. [OB] A table needs a primary key.
create table depends
(uses varchar(80) not null,
usedby varchar(80) not null,
unique deps (usedby,uses));
# naming the index is unnecessary, but may be a convenience
Btw, why not represent a leaf node by usedby=NULL? That would give a faster select for leaf/branch.