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