Better Programming

Advice for programmers.

Follow publication

Member-only story

8 Super-useful SQL Snippets You’ll Want to Have on Hand

Kesk -*-
Better Programming
Published in
4 min readDec 30, 2021
Photo by Lucas DC from Pexels

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.

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Kesk -*-
Kesk -*-

Written by Kesk -*-

Software engineer - software Enthusiast - Sci-Fi writer.

Responses (4)

Write a response