#Database state copy

4 messages · Page 1 of 1 (latest)

vast kernel
#

I am working on a project which involved creating a "What if" scenario. That means we would like to run some simulations on another state of our database and then compare it to the main state / baseline. Also we can have multiple database state, created one from another. What would be the best approach in this case for creating database copies, then work with these copies in parallel?

Assuming I am using PostgreSQL.

I was thinking about multiple schemas for each state of the db, but I am not sure how to copy data from one schema to another, then how to pull data from 2 different schemas at the same time and do comparison?

Let me know if you have any other ideas in mind.

Thank you.

odd vale
#

Can you expand on what state of database means? In what ways would one state differ from another?

#

If it's just the data you could use something like btrfs.

manic jetty
#

For doing comparisons between two different databases using Django, you could read about Django's multi database support (https://docs.djangoproject.com/en/5.0/topics/db/multi-db/). The section about "Manually selecting a database for a QuerySet" would be helpful for doing comparisons between two databases. Regarding copying databases, I don't know any advanced techniques and when I need multiple copies I use pg_dump and restore the data to a new database.