-2

Our server gets slow, "To get data from mysql database". So I search for it on google. They told me, "Use INDEX for the select query to get data from the database it becomes more fastest execution".

  • completely true. Thanks for the information. – Conffusion Sep 05 '19 at 09:12
  • enable slow_log, run explain on the queries and make sensable indexes for those queries or maybe a query rewite is even needed.. But keep in mind adding a index does not force MySQL into using it as the optimizer is costs based.. Don't just blindly add indexes as redundent indexes might confuse the optimizer into using a wrong index and worse performance.. – Raymond Nijland Sep 05 '19 at 09:25
  • maybe u can have a look on this https://stackoverflow.com/a/29842947/11930311 – MannersW Sep 05 '19 at 09:31
  • I have executed this query "CREATE INDEX identifier_idx ON room_info(identifier);" in my local system, [ it's affected 0 rows ]. But does not create any INDEX on it. – sharath3599201 Sep 05 '19 at 09:39

1 Answers1

0

Index is a small copy of a database table sorted by key values.

U need to create index first.

CREATE INDEX index_name ON table_name(column_name)   

Then:

SELECT * FROM table_name
USE INDEX (index_name)
WHERE condition;
MannersW
  • 93
  • 9