code:
1
2
3
4
5
6
7
8
9
| CREATE TABLE replys ( threadid mediumint(6) NOT NULL default '0', replyid mediumint(7) NOT NULL auto_increment, status tinyint(1) NOT NULL default '2', timestamp int(10) NOT NULL default '0', userid smallint(5) NOT NULL default '0', content text NOT NULL, PRIMARY KEY (replyid) ) TYPE=MyISAM; |
Ik heb dus table replys, en nu wil ik de kolommen 'threadid' en 'replyid auto_increment' indexeren, omdat ik daar dus vaak op select.
Nou had ik dus eerst PRIMARY KEY (threadid,replyid) maar toen ging er wat mis, want wanneer threadid veranderde kon replyid wel weer vanaf 1 beginnen want samen waren ze weer uniek. Dat is dus niet de bedoeling.

Hoe indexeer ik deze tabel zo dat ik wel optimale snelheid heb, en 'replyid auto_increment' wel netjes doortelt ?