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:
- “SELECT * WHERE pageid = xxxx”
- “SELECT * WHERE visitorid = xxx AND pageid = xxxx”
- “SELECT visitorid, MIN(time) AS mintime WHERE pageid = xxxx GROUP BY visitorid”
In the future I might use maintestid in queries too. So this would look like:
- “SELECT * WHERE maintestid = xxxx”
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?
idcolumn onlypageidonly 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)