Creating unlogged (PostgreSQL) tables in Rails
13-Aug-2020 1701
One of the most important aspects of a relational database is durability. The database has to make certain guarantees which add overhead to the database system. But what if you want to give up on the durability aspect and increase the speed instead?This can be especially be done in test environment where one may not care about the durability aspect and want to run tests faster. PostgreSQL supports multiple settings for non durability which forgo data integrity and can increase the performance. One such thing is unlogged tables.Data written to unlogged tables is not written to the write-ahead log which makes them considerably faster than ordinary tables. But it comes with a rider. These tables are not crash proof. Whenever there is a crash or unintended shutdown, such tables are truncated.But they can be used in test environment where we don't really care about the durability aspect. They can also be used for temporary tables which are recreated even if they are wiped out. We can create unlogged tables as follows.
Creating unlogged (PostgreSQL) tables in Rails #ruby #rubydeveloper #rubyonrails #Creating #unlogged #(PostgreSQL) #tables #Rails https://rubyonrails.ba/link/creating-unlogged-postgresql-tables-in-rails