Member-only story
8 Super-useful SQL Snippets You’ll Want to Have on Hand
Basic SQL statements that will save you time

The year is ending, and in this last post of 2021, I leave eight little tips that can save you time in your day-to-day as a programmer.
Some are basic while others could be a little complex. But I think they are handy, so without wasting more time, let’s get started.
1. Search for repeated rows by column name
With this simple query, we can get the list of rows that have the same value specified in the column_name
field.
In addition, we can see the number of times they are duplicated.
2. Show the indexes of a Database schema
Although this is something that you can see from your database client, we can also do it with a SQL statement.
3. Show the N most expensive queries
This sentence, which seems very complicated but is not, shows you which sentences have taken the most time for the database engine to execute.
It is handy to know which SQL statements need a review to see if they can be optimized.
4. Show whether an index is used or not
Commonly, the number of indexes in a database increases over time.