In this blog post, I will tell you some queries/ tricks to speed up your application using the power of a database. I am using Postgres and ActiveRecord rails, so all questions are related to these, but you can tell them with your database.
Recently I got some performance issues when our user base increased many folds. We did some optimization and would like to share the tips:
Note: As I am using ActiveRecord, most of the examples have ActiveRecord syntax with corresponding SQL statement
Select only required fields from the database – Not all
Most developers fail to specify the necessary columns and instead select all fields from the database, leading to performance degradation.
Let us say my User Table has 100 users.
The above query took 15.4 ms to select all columns from the table. But, the question below took only 3.3ms.
Here we are not…
In this blog post, I am going to tell you some queries/ tricks to speed up your application by using the power of database. I am using postgres and activerecord rails so all queries are related to these, but you can relate it with your database.
Recently I got some performance issue when our user base increased many folds. We did some optmization and would like to share the tips:
Note: As I am using ActiveRecord most of the examples have ActiveRecord syntax with corresponding SQL statement
Select only required fields from database – Not all
Mostly developers miss to specify the required columns and instead select all fields from database which leads to performance degradation.
Let us say my User Table has 100 users
Above query took 15.4 ms as it is selecting all columns from the table. But, the query below took only 3.3ms.
Here we are not…
View original post 744 more words