Re: Diffrence in 'add index' question Q wrote:
> Suppose table:
>
>
> CREATE TABLE `testtable` (
> `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
> `fieldA` INT NOT NULL ,
> `fieldB` INT NOT NULL ,
> `fieldC` INT NOT NULL ,
> `fieldD` INT NOT NULL
> ) ENGINE = MYISAM ;
>
> What's the diffrence between:
> ALTER TABLE `testtable` ADD INDEX ( `fieldA` )
> ALTER TABLE `testtable` ADD INDEX ( `fieldB` )
> ALTER TABLE `testtable` ADD INDEX ( `fieldC` )
>
> ...And:
> ALTER TABLE `testtable` ADD INDEX ( `fieldA` , `fieldB` , `fieldC` ) ;
>
>
> Take care,
> Quarco
The former will create 3 indexes, allowing you fast access (and or sorting)
to data based on any of the 3 fields.
The latter will only build one index and the speed improvement will
(broadly) be limited to queries based on fieldA. |