Welcome to AggreGate Community

How to estimate SQL DB size

Questions related to relational databases, key-value databases, NoSQL databases, round-robin databases, and file-based storage.

How to estimate SQL DB size

Postby moskons&gmail.com » Sun Oct 31, 2021 9:14 pm

Use the following SQL query:

1) PostgreSQL
Code: Select all
 SELECT pg_database_size('database_name');
Function pg_database_size gives size of DB in bytes.


2) MySQL
Code: Select all
 SELECT table_schema "DB Name",
 Round(Sum(data_length + index_length) / 1024 / 1024, 1) "DB Size in MB"
 FROM information_schema.tables
 GROUP BY table_schema;

This query gives size of all DB.

If you need one DB, use condition for example - WHERE table_schema = "aggregate"

3) Oracle
Code: Select all
 SELECT round((sum(bytes)/1048576/1024),2) "Total(GB)" FROM V$DATAFILE;

This query gives size of DB.
moskons&gmail.com
 
Posts: 21
Joined: Mon Sep 20, 2021 3:41 pm

Re: How to estimate SQL DB size

Postby moskons&gmail.com » Tue Nov 23, 2021 9:11 am

The message can be supplemented
moskons&gmail.com
 
Posts: 21
Joined: Mon Sep 20, 2021 3:41 pm


Return to Data Storage

Who is online

Users browsing this forum: No registered users and 1 guest