On Wed, Jan 17, 2018 at 9:10 AM, Graham Leggett <minf...@sharp.fm> wrote:
> > db=# select count(s.nspname) from pg_class c join pg_namespace s on s.oid > = c.relnamespace where s.nspname in ('public'); > count > ------- > 0 > (1 row) > > It is based on the idea that the database is not empty if there are any > class entries in the “public” namespace? > > That was my original thought - though comparing the size of template1 to the target database should be reasonably safe... If you do go for object detection you will want to ensure that no schemas other than public exist in addition to ensuring that public is empty. That doesn't prevent people from installing stuff to pg_catalog but normally only extensions would end up there. David J.