'Can we do bulk write and read from same Postgres Table?
We run a cron every 15min which get some data from somewhere and inserts into the main table(basically appends), which is then used for reading in production. So not to perform read and write in the same table, we use 2 tables(temp and main). First we get data and insert into temp table, then we rename temp and main table(using a 3rd table), so basically temp becomes main and main becomes temp, and then we make temp equivalent to main(basically truncating temp, and inserting everything from main), so in the end we have identical data in both table.
I am not sure if this is the correct, but is there any better way of doing this?
We are not performing read and write on same table because there can be bulk write which can happen(because of cron) and at that time our read performance can be affected
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
