I have very starnge behavior on Azure PostgreSQL server.
I try to read DB size using the next query:
SELECT CAST(pg_database_size(current_database()) * 1.0/(1024 * 1024) AS DECIMAL(12, 5))
But this query runs very long and I have timeout exception in my C# application:
Exception while reading from stream; Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
I have no idea why pg_database_size takes a lot of time...
To resolve my problem I see two options:
- Increase query performance using Azure PostgreSQL Server settings
- Replace the current query to another query with some result
I'm open for any suggestions. Please give me any ideas about how I can read DB size fast and correctly.