Skip to content

emsamarante/QueriesComparison

Repository files navigation

Queries Comparison

You have a dataset of sails and you wannt to know which seller is third spot in sales. How would you write the query?

Technologies used in this roject:

MySQL Docker Ubuntu

In this project I show 3 queries which gives the same result, but with their performances totally diferent.

To build this project I use MySQL running in docker and DBeaver interface. If you want to reproduce this project you can follow the intallation steps in this link: https://medium.com/@edu18ds/running-mysql-in-container-docker-and-setting-dbeaver-5f9e5781649d

The dataset and scripts are in this repository.

The picture below shows the dataset:

Dataset

First Query - The best performance.

Query 1

Second Query - with subquery

Query 2

Third query - version 1: window function and subquery

Query 3

Third query - version 2: window function, subquery and LIMIT result

Query 3

Conclusion

In spite of having the same result, the cost of each query is diferent. So, depending on the amount of data it is very important to stay stuned in performance issue. When we limit the amount of lines we can get better performances. It is important to mention that the first query has the best performance and it is more readable.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published