Forum Moderators: phranque
Cybane
A bit more information about the table might help, but I would say choose one entry as the primary key and just place indexes on the other two.
Or do you mean that the row can only be uniquely identified by looking at the combination of all three keys?
Typically you should try to keep your indexing as little as possible on high write tables. It's a balance thing, and takes some work throughs.
Here are two sites which have tutorials on this.
[databasejournal.com...]
and
[devshed.com...]
webadept is correct in that having a large number of indexes on a "write" table will slow inserts down.
Don't worry about insert speed for now. I've found I can get decent speed inserting over 2000 records on a fulltext index with over 100,000 entries with a little db tuning voodoo.
In mysql fixed tables (tables that don't have varchar, text or blob types) are MUCH faster than dynamic tables, so where possible, try to use char(20) rather than varchar(20). The performance is faster but the cost is a little bit more disk space.
It really depends what you want to do. If you want to be able to query your table on any one of the keys then PRIMARY KEY (field1,field2,field3) is not the answer. The above will give you performance increases on searches that specify (field1) or (field1, field2) or (field1, field2, field3) but not if you're only searching on field2 or field3 for example. See here for details:
[mysql.com...]
If you want to search on all three columns individually, create indexes on all three columns and make them unique.
Mark.