Re: Is there a "right" way to test if a database is empty? - Mailing list pgsql-hackers

From hubert depesz lubaczewski
Subject Re: Is there a "right" way to test if a database is empty?
Date
Msg-id 20180118110424.GA1012@depesz.com
Whole thread Raw
In response to Is there a "right" way to test if a database is empty?  (Graham Leggett <minfrin@sharp.fm>)
List pgsql-hackers
On Wed, Jan 17, 2018 at 05:47:16PM +0200, Graham Leggett wrote:
> I need to test whether a database is empty, in other words “createdb”
> has been executed but no data of any kind appears in that database.
> What is the correct postgresql way to do this?

There is none, because it highly depends on how you'll define empty.

Please note that even directly after "create database x;" your db might
not be empty, if you had some things created earlier in template1.

Best regards,

depesz



pgsql-hackers by date:

Previous
From: Amit Langote
Date:
Subject: Re: [Sender Address Forgery]Re: [Sender Address Forgery]Re: [SenderAddress Forgery]Re: [HACKERS] path toward faster partition pruning
Next
From: Thomas Munro
Date:
Subject: Re: [HACKERS] Planning counters in pg_stat_statements