mla/pg_sample

Sampling a remote database

propupul opened this issue · 1 comments

Hello!

Thank you for this wonderful project, I've been playing around with pg_sample and it is simply great, this is not really an issue but more of a question of the order of operations.
First, if I understand correctly you cannot use pg_sample to get a database from a remote host if you don't have write permission on that database is that correct?

If the first assumption is correct then the order of operations is: pg_dump, pg_restore and then pg_sample?

Lastly, why does the script need write permission? I'm sorry if I'm missing something obvious but I'm fairly new to databases in general.

All the best!

mla commented

Thanks!

First, if I understand correctly you cannot use pg_sample to get a database from a remote host if you don't have write permission on that database is that correct?

If the first assumption is correct then the order of operations is: pg_dump, pg_restore and then pg_sample?

Yes, although if it's easy for you to do a pg_dump and pg_restore, then you may not need pg_sample. I use it in cases where I have a very large development database, for example, and I want a smaller version for local dev work on my laptop, etc.

Lastly, why does the script need write permission? I'm sorry if I'm missing something obvious but I'm fairly new to databases in general.

pg_sample creates a small clone of the target database under a specific schema (_pg_sample schema, by default), which is where the write permission comes in. You could potentially implement it other ways, without needing write access, but that's not what I did ;)