M
M
maksam072021-04-03 11:09:07
MySQL
maksam07, 2021-04-03 11:09:07

Composite indexing at the table, explain?

Good afternoon. I am working on the issue of indexing data in the table and due to a bunch of variations in the development of the event, I do not fully understand what indexes should be in different situations:
1. 2.
SELECT * FROM table_name WHERE col1 = 1;

SELECT * FROM table_name WHERE col1 = 1 AND col2 = 2;

3.
SELECT * FROM table_name WHERE col1 = 1 AND col2 = 2 ORDER BY col3 ASC;

4.
SELECT * FROM table_name WHERE col1 = 1 AND col2 = 2 ORDER BY col3 ASC, col4 DESC;

5.
SELECT * FROM table_name WHERE col1 = 1 AND col2 = 1 AND col3 = 1 OR col4 = 1 ORDER BY col3 ASC, col4 DESC;


The only thing I'm sure of is:
1. If you can, write examples for each option, or perhaps there is some material that explains well for indexes. Interested in how it works, for example, in an online store, where filtering can be in ten columns?
CREATE INDEX col1 ON table_name (col1);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lazy @BojackHorseman MySQL, 2021-04-03
Tag

8.3.1 How MySQL Uses Indexes
in online stores use different storage models or engines

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question