Gary
Gary

Reputation: 2167

How to create an index on a Time_Stamp column in MySQL?

I have a MySQL database table with over 2 million rows, and I am trying to Query for records for specific times from my Time_Stamp column.

As expected, the Query takes a very long time to execute.

I have read that the best way to optimize this type of query is to index the time_stamp, but I have not been able to find methods on how to do this.

My main questions are as follows:

Upvotes: 0

Views: 129

Answers (1)

ScaisEdge
ScaisEdge

Reputation: 133370

You can add an index with create index

CREATE INDEX index_name ON table_name (column_name)

For second question . adding an index can change the query optimization do the fact that the index are evaluated for find the best scan strategy by the database engine for this you can take a look ad this chapter on mysql docs https://dev.mysql.com/doc/refman/5.5/en/optimization-indexes.html

Upvotes: 3

Related Questions