tags: PostgreSQL

change_table with Bulk Option Combines Multiple alter-table Statements

Today I learned that when doing database-migration on Rails, change_table :#{table_name}, bulk: true let us combine multiple alter-table statements and it could reduce the cost of the whole alteration. That is, instead of executing multiple alter-table separately, def change add_column :users, :first_name, :string, null: false add_column :users, :last_name, :string, null: false end we can run a single alter-table statement by change_table like as follows. def change change_table :users, bulk: true do |t| t.

Read more →

How to Fix PostgreSQL Error: canceling statement due to conflict with recovery

Today I learned how to fix a PostgreSQL error like this: ERROR: canceling statement due to conflict with recovery DETAIL: User query might have needed to see row versions that must be removed. It's about database replication. I have been getting that on read-only database which uses PostgreSQL Hot Standby. This error didn't happen always but happened occasionally. I fixed that by setting both max_standby_archive_delay and max_standby_streaming_delay to a longer time (300s) on the standby servers.

Read more →

Gentaro "hibariya" Terada

Otaka-no-mori, Chiba, Japan
Email me

Likes Ruby, Internet, and Programming.