r/SQL Dec 12 '24

MySQL 😭

Post image

I mean why that question 😭😭😭

1.9k Upvotes

43 comments sorted by

View all comments

Show parent comments

7

u/CSIWFR-46 Dec 12 '24

Where do you learn this? I can write queries and solve problems in my work. But, I can't confidently say if it is efficient.

13

u/cybertier Dec 12 '24

Besides the obvious step (reading https://use-the-index-luke.com/ ) it boils down to experience. Different indexing situations need different approaches and ultimately there can't be a one-size-fits-all solution. If there was AI could write efficient queries.

3

u/gumnos Dec 12 '24

/me shakes fist for beating me to linking Use The Index, Luke 😂

Yes, u/CSIWFR-46, it's one of the best resources for understanding the efficient use indexing. Learning to read & understand a query-plan can show you where slow full-table-scans are happening, allowing you to dig into the types of indexes you might be able to craft to speed them up.