mysql - Should I also index columns included in a PRIMARY KEY? -
This question suddenly went into my head ... I have a table which, based on their ID, I I I am wondering if there is a need to include those previous two By using that column independently of create table looks like this:
create table 'ticket_content' (`ticket_ID` INT not tap, 'entity_id' INT not zero, 'indicated DO 'INT NO FAL DEFAULT 0, Primary key (`Ticket_ID`,` unit_ID`), key `ticket_id` (` ticket_ID`), key `unit_id` (` entity_id`))
key
lines, will I get better speed with the following questions, or do the individual columns automatically under the primary key
Will be indexed from?
SELECT * ticket_contact WHERE ticket_id = 1; SELECT * ticket from ticket_contact WHERE entity_id = 1; The index created by
primary key
is identical to any Other (potential mixed) UNIQUE
index therefore you do not need to create a separate index for ticket_id
because it is in (ticket_id, entity_id)
index The main column is included in the form. ticket_id
entity_id
Comments
Post a Comment