bart2puck
bart2puck

Reputation: 2522

How to create an index on a date column

I have a mysql table that has a date column. I have approx 800,000 rows in the table so I want to index. The most common search is going to be:

  Select X,Y,Z from table where dateField='yyyy-mm-dd';

the date is in standard mysql yyyy-mm-dd format.

what type of index do i want to create?

CREATE INDEX 2013- ON customer (date(10));

or

CREATE INDEX 201 ON customer (date(10));

or am I way off?

I am new to indexing so any help would be great.

Upvotes: 0

Views: 172

Answers (1)

Ike Walker
Ike Walker

Reputation: 65547

Just add an index on dateField and give it a simple name, such as the column name.

For example:

alter table your_table
  add index dateField (dateField);

Upvotes: 2

Related Questions