sql - Indexes and multi column primary keys -


was searched and did not find the answer to this specific noob question.

I have a table with the following primary key in a MySQL database

Primary key ID (invoice, item)

In my application, Item "and will only be less often on" invoices. " I'm assuming that indexing on these columns would benefit me.

MySQL does not complain when I define the following:

INDEX (invoice), index (item), primary key ID (invoice, item)

< P> But I do not see any evidence (using Desreebie - the only way I know how to see) is that different indexes have been set up for these two columns.

The question is, is there a column that automatically indexes a primary key? Also, is there a better way of DESCRIBE to detect the structure of my table?

I am not familiar with the internal familiarity of the indices on my SSL, but on two database vendor products I am familiar with (MSSQL, Oracle) index, balanced-tree structures, whose nodes are arranged in indexed tubal, on which the index is defined ( defined in the order )

Therefore, unless my SQL Does not do very differently, (probably not), any accumulated index (multiple columns) may be usable from any query, according to which the list indicates columns Columns are required to filter or sort by subset , that is, if the column is indexed as the indexed list of columns in the entire index, the complete set of index An order was given Has a reset, which starts from the beginning of the actual index sequence in other words, before intervals, this means that if you have an index (A, B, C, D), then that question is (A), (A, B) is filtered. , Or (A, B, C) index, but will not be able to use a query index that needs to filter on (B), or (C) or (B, C) ... < / P>

So in your case, if you often need to filter or sort the columns on items , then you can add another index Must be added in ..


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -