I'm using MySQL with InnoDB.
I don't need a primary key in terms of semantics, so does a primary key (or rather, a unique index) make for faster queries than a non-unique index?
I have two columns that are suitable for indexes but are non-unique. However, combinations of the two columns are always unique. The columns are also non-null.
Is it better to just set the two non-unique columns as indexes, or to instead create a primary key over the combination of the two columns?
The access pattern will normally be modifying two or four rows where the first column is a given value (and the second column will be different, as I mentioned every combination is unique).
For example, col1 and col2 being like
1 1
1 2
1 3
1 5
2 1
2 2
2 3
2 5
3 1
3 2
3 3
an example would be change rows (1, 2) and (1, 3) at a time
A follow up question is about datatypes. col1 fits in a smallint and col2 in a tinyint. However, I'm not sure what the performance implications are of using smaller-than-int types and also different types, when combining into a single index. The manual says multiple columns are concatenated when used for primary key. Is it better to use the same type, smallint? Or even use ints? In terms of memory access, are not aligned, full word accesses the fastest? Does this have an impact here?