Data analysis

0
Hello, Our database space is running out so we're thinking maybe we should clean up any data that's not in use in the app. Is there any way to view some analytics on how much space what data (by entity) is taking up the database? The only thing I was able to find was datadog but it’s for Mendix cloud version v4, and we are running on Mendix cloud version v3.   Thank you.
asked
2 answers
3

Download a backup of the database and restore it locally in Postgres. Postgres has some analyses tools to see how much data each entity has.

Regards,

Ronald

 

answered
0

Just do it live on the system.

Using  com.mendix.core.Core.dataStorage() you can run SELECT pg_size_pretty( pg_database_size($YOURDBNAME) ) . This will provide you with an overview. Running  SELECT nspname || '.' || relname AS "relation", pg_size_pretty(pg_total_relation_size(C.oid)) AS "total_size" FROM pg_class C LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace) WHERE nspname NOT IN ('pg_catalog', 'information_schema') AND C.relkind <> 'i' AND nspname !~ '^pg_toast' ORDER BY pg_total_relation_size(C.oid) DESC will provide you with an overview per relation.

For the cloudboxes, you can get the database name as follows:

com.mendix.core.Core.dataStorage().executeWithConnection(
	function(a){
		try{
		    dbname=a.getCatalog();
		}catch(e){
		    alert(e);
		}
	}
);

Sample output:

Overview:

Details:

 

answered