Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysql - how to run query without index

I am looking to compare indexes and further optimize my code. What I would like to do is force the query to run without an index so I can see what difference it has made. Is it possible to do this?

like image 426
Robbo_UK Avatar asked Jun 20 '13 08:06

Robbo_UK


People also ask

Does SQL query work without index?

SQL query will not automatically eliminate the duplicates , explicitily we have to use distinct keyword for removing duplicates from result set. If there is no indexes it will create index automatically. No two column can have the same name.

Does MySQL use index for in query?

The USE INDEX ( index_list ) hint tells MySQL to use only one of the named indexes to find rows in the table. The alternative syntax IGNORE INDEX ( index_list ) tells MySQL to not use some particular index or indexes.

What is the use of <> in MySQL?

The symbol <> in MySQL is same as not equal to operator (!=). Both gives the result in boolean or tinyint(1). If the condition becomes true, then the result will be 1 otherwise 0.

Why MySQL do not use index?

The Benefits and Drawbacks of Using Indexes in MySQLIndexes consume disk space. Indexes degrade the performance of INSERT, UPDATE and DELETE queries – when data is updated, the index needs to be updated together with it. MySQL does not protect you from using multiple types of indexes at the same time.


1 Answers

Yes, you can ask the query to not use indexes by adding IGNORE INDEX (index1, index2, ...) to your query. More details can be found here.

Note: I know this is an old question and you would already have found the answer, but I hope this will help others looking for the same answer, and they wouldn't have to spend their valuable time digging through the MySQL docs.

like image 50
Optimus Avatar answered Oct 06 '22 01:10

Optimus