Are multiple indexes needed for multiple sentences?

Let's say I have a request:

SELECT * FROM users WHERE username = 'test' AND somethingelse = 'test'

I am wondering if both columns need to be indexed for optimization. At first, MySQL finds all columns of the username with the value "test", and then looks at these results for the columns "all" using "test"? Or is this happening at the same time?

+3
source share
1 answer

Yes you need. Each column and combination of columns that appear in the WHERE clause must have an index for effective searches.

You avoid it for primary key fields because an index is created for them because it is declared as a primary key. Other columns require you to index them.

, .

, .

+4

Source: https://habr.com/ru/post/1757977/


All Articles