Alan A
Alan A

Reputation: 2551

MYSQL indexing needed?

I am storing the match odds of sports matches/events in a MYSQl table.

The structure is as follows:

I can uniquely identify each row by match_id, outcome_id and bookmaker_id. So do I actually need the odds_id. For purposes of order and logic it seems as if I should have one, but the odds_id is meaningless to the user. The table will store a high volume of rows and although the odds_id is set to be auto increment if any odds are deleted the sequence will be thrown.

Will the presence of this index impact upon performance or will it be negligible and therefore ok to leave it in place.

Thank you in advance.

Alan.

Upvotes: 0

Views: 49

Answers (1)

zozo
zozo

Reputation: 8582

If you don't use this table in any joins or whatever, and you usually need the combination between match outcome and bookmaker you can cut the odds index and add an index on the combination (well... not the best word but can't think at any other) of the 3 columns.

If you need to join this table with something else by using the odds_id... you should index it separately.

About the autoincrement... you can set it only on the primary key, witch is already an index. So if you keep the AI you add the index regardless of what you want.

The index impact is almost never negligible so is better to do it right.

Upvotes: 1

Related Questions