If I often order o.creationDate - should I mark createDate with @Index?

I know that indexes in a database are a good way to improve query performance, but how much performance would I gain by creating an index for the createDate property of this object, which I often order createDate in my queries? Will this “order from o.creationDate” justify creating an index for the createDate property?

+3
source share
2 answers

Yes, if the result set returned from your selection is large. Remember that ordering (logically) is done in the result set after filtering, but a good optimizer can use the index during filtering to order. If you return a five-row result set, the ordering is trivial. If it contains a million rows, then a specific index (B-Tree) will definitely help. However, the hash index did not help.

For more information about MySQL and indexes for ORDER BY columns, see the following article: Database Index Tips

+1
source

/, , ? , creationDate . ORDER BY.

, - : , , . , , , , , .

+1

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


All Articles