HMdeveloper
HMdeveloper

Reputation: 2884

select query is slow

I have a table in my sql with a 1000 of data and I am using the following sql query

select entityID,name from entity where DataItemId=2020

but it takes around 40 or 50 sec to extract the data and it is not acceptable

Upvotes: 1

Views: 123

Answers (3)

You can create an Index on your search column if it is not the primary key column. It will increase the performance Check this for MySQL Indexing

Upvotes: 1

cmd
cmd

Reputation: 11841

To improve performance, create an index on DataItemId. If DataItemId is the identity column, make it the primary key.

Upvotes: 1

Scary Wombat
Scary Wombat

Reputation: 44854

You should create an index on the DataItemId column.

see http://dev.mysql.com/doc/refman/5.0/en/create-index.html

This type of query should have sub-second performance

Upvotes: 3

Related Questions