I need to optimize my MariaDB tables index. I’ve read a lot of very interesting things on StackExchange, but I’m not sure to have the answer for my case.
In my case, I have a table named TableA
which contains more than 40 millions records (stats purposes) with these columns :
ID
(PK)A
(INT)B
(INT)C
(INT)D
(INT)
I make different queries on this table, with many of the 4 columns in the WHERE
clause. For example, I can have these columns in WHERE
clause of the same query :
- A, B and C
- A and B
- A and D
- A, C and D
- B and D
- B, C and D
- C and D
- only A
- only B
- etc.
I can encounter every case. What would be the best way to index that table which count more than 40 millions records ? Should I make only one INDEX with all 4 columns ? Or 4 different indexes ? This table is used everytime in my app, and contains sensitive data…(for stats purposes).
Thank you for your help !
Joffrey