Postgres dump of only parts of tables for a dev snapshot

后端 未结 3 1150
日久生厌
日久生厌 2020-12-12 15:51

On production our database is a few hundred gigabytes in size. For development and testing, we need to create snapshots of this database that are functionally equivalent, bu

3条回答
  •  长情又很酷
    2020-12-12 16:24

    On your larger tables you can use the COPY command to pull out subsets...

    COPY (SELECT * FROM mytable WHERE ...) TO '/tmp/myfile.tsv'
    
    COPY mytable FROM 'myfile.tsv'
    

    https://www.postgresql.org/docs/current/static/sql-copy.html

    You should consider maintaining a set of development data rather than just pulling a subset of your production. In the case that you're writing unit tests, you could use the same data that is required for the tests, trying to hit all of the possible use cases.

提交回复
热议问题