If I create a table like so:
CREATE TABLE something (column1, column2, PRIMARY KEY (column1, column2));
Neither column1 nor column2 are unique by themselves. However, I will do most of my queries on column1.
Does the multi column primary key create an index for both columns separately? I would think that if you specify a multi column primary key it would index them together, but I really don’t know.
Would there be any performance benefit to adding a UNIQUE INDEX on column1?
There will probably not be a performance benefit, because queries against
col1=xxx and col2=yyywould use the same index as queries likecol1=zzzwith no mention of col2. But my experience is only Oracle, SQL Server, Ingres, and MySQL. I don’t know for sure.