R
R
Roman Sarvarov2021-08-25 15:31:54
MySQL
Roman Sarvarov, 2021-08-25 15:31:54

Should I add indexes?

For example, there is a table according to some entity, for example, with apartments:
- id
- floor (floor)
- area_size (area)
- room_count (number of rooms)
- created_at

By default, when entering my site, sorting is done by creation date ( created_at field), but you can choose to sort by all other values.
There is also a filter to search for all values ​​(including combined ones).

As I know, the index must be added to the fields that participate in where, join, order by, group by.
Do I really need to add an index to all these fields?
Or add only on created_at?
Or not add at all?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lazy @BojackHorseman MySQL, 2021-08-25
@megakor

add as many indexes as needed to optimize all queries

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question