I have a database (in MySQL, using InnoDB) that I am using for texture identification in a 3D image. In it, there will be a table of texels(texture pixels) with hue included, in the form of:
texelid INT (PK AI NN)
texelx TINYINT (NN)
texely TINYINT (NN)
texelhue INT (NN)
identifiedtex INT (NN)
Identifiedtex is a foreign key in a 1:N relation of one identifiedtex to many texels(texture elements)
If I create an index(B-tree) using texelx
, texely
, and texelhue
then I can quickly find a row. However, if I add identifiedtex
as the last column indexed in the index, will this speed up a lookup of the texture since the result is part of the index? Just as a note, a combination of texelx, texely, and texelhue will result in multiple identifiedtex's, and a few different rows will need to be looked up to identify the texture.
I plan to identify textures by using an inner join against the same table(self join) in order to find rows that have a matching X, matching Y, and matching hue, and grouping by distinct identifiedtex's.
SHOW CREATE TABLE texeltblname\G
and show its result.WHERE
,GROUP BY
andORDER BY
clauses usually give clues as to what indexes to create.