Forum Moderators: open
Are there any coding techniques that are recommended for improving the reading time of small MySQL tables?
My site reads a few for page generation and, although the site is hardly slow, it's one area that could be improved.
Either SQL coding or the way my tables are defined.
If they are small, will having indexes be slowing them down? If so, should I have a unique field in preference to an index, for instance?
All help appreciated.
David.
in very general terms:
you usually want indexes on any column(s) you will be using in a where clause, ordering, grouping, etc.
there is a cost to maintaining indexes however, so if your table gets more inserts/updates than selects, you might want to skip the indexing.
if the tables are small and static, indexes can't hurt.
only through testing can you be sure.
you should do timing tests first to see what percentage of time is actually spent on queries.
if you make it twice as fast but db is only two percent of your time, you haven't improved much overall after the effort...