Sorry for the late reply but I’ve been really busy
lol I love people with some sense of humous
[quote=“silly2988, post:3, topic:214686”]
what is the best way to determine your indexes are properly set with the queries you use?
[/quote] Any field that will be used in searches, that should be indexed.
When I mean used in searches I mean really used frequently.
Example, for a client database, it is likely that I will use the client number, or the last name to do my search. Most of the time, client number will be the primary key of the table and, by definition of primary key, it will already be indexed.
It least likely that people will search by first name, phone number (well, unless you’re Domino’s pizza or similar) or e-mail address. So I will not index those.
I can still do searches using those fields but it will take more time (sometimes a lot of more time) to get the outcome. But since they will only be used exceptionally, I will not index those.
But how do I know if I’m really guessing right? By asking the people who will use it which fields they will need to search, how they’re used to search.
If a field is a foreign key, it should be indexed too.
I always try to add just the right amount of indexes. The right amount speeds the results of the queries. Too many indexes will slow it down.
So, if even before planning the database structure, you have the right information about the project, you’ll know which fields should be indexed.
I hope I made myself clear. I’m too tired
And, as @Mittineague said, you can always test the results by using EXPLAIN