Posts

Showing posts from April, 2023

Rails Sync Postgresql and Elasticsearch Database of a Model

Hi, This is  Shubham Mishra  from India,  this is the part of  Ruby on Rails  exploration journey.  In this post we will discuss about how can we keep Postgresql (a SQLDB) and Elasticsearch (a nonSQL DB) with the help of a background job processor and I am sure you will get excited to make your hands dirty with those code, so why to wait let's get started... Most of the time due to increase in DB record size we try to split our DB into two DB based on the requirement like one is Transaction oriented (SQL DB) and another Search oriented (Non SQL DB) with limited data. In my case we have Postgresql for storing all the records and used for entire business operation and for Search support we have elasticsearch with minimum indexes (tables) and their entire documents. For better understanding lets consider in PG DB we have Employee table with id, name, dob, address etc and some more other tables, whereas in Elasticsearch we have only Employee index (table) with all its documents dupli

Rails Postgresql Query timeout set and skip during migration

Hi, I am  Shubham Mishra  from India,  this is the part of  Ruby on Rails  exploration journey.  In this post we will discuss about the rails DB (Postgresql) query time out setting and how can we avoid this timeout setting during migration and I am sure you will get excited to make your hands dirty with those code, so why to wait let's get started... Question: Rails and postgresql I want to set query timeout to 10 sec but skip to check this timeout setting during rails migration how can i achieve? Answer: To set a query timeout of 10 seconds for PostgreSQL in a Rails application, you can use the statement_timeout configuration option in your database.yml file. Here is an example configuration that sets the query timeout to 10 seconds: This will set the query timeout to 10 seconds for all queries executed by the PostgreSQL adapter in the production environment. To skip checking the query timeout setting during Rails migrations, you can use a custom connection adapter tha