---

When To Use Indexes In MySQL

“This comes up in discussions almost every new project I work
on, because it’s a very important thing to consider when designing
a database. When deciding when and how to create an index in your
MySQL database, it’s important to consider how the data is being
used.

“Let’s say you have a database of employees. We will create it
like this:

CREATE TABLE employees (
 ID INT,
 name VARCHAR(60),
 salary decimal(10,2),
 date hired(date)
 ) 

“So you will notice that this table is pretty simplistic, and
doesn’t really contain all the info you would need to actually
manage employees, but its just for the sake of demonstration, and
you could always add more later, or even make another table and use
joins if you had really complex needs.”

Complete
Story

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends, & analysis