Reputation: 7780
I have a table called clicks which records mouse clicks around a website. The schema looks like this:
There are 3 main queries run on this data:
In the future I might use maintestid in queries too. So this would look like:
So I've added 2 indexes to the table for both these queries along with the primary key like so:
I have 3 questions:
Is this primary key useful at all being like this? Or should I make it the ID column only?
Is the pageid index useful at all? Or will it be just as fast if all queries for pageid are be handled by the pageid_visid index?
When I want to search via maintestid in the future, should I just add an index on the maintestid column, or something different?
Upvotes: 2
Views: 1230
Reputation: 425358
id
column onlypageid
only index is slightly useful in that its entries will fit on less index pages, but I would drop it and let mysql use the other pageid-based index (do a benchmark test to confirm)Upvotes: 4
Reputation: 105
Why would you want to do this?
Anyway, if you want to have them pageid, pageid_visid and maintestid as indexes then it's all fine.. but it will be better if you have only one id as primary since it is more appropriate. anyway, you could query them all using the other id's
Upvotes: 0