Issue #2968: Getting the database file size

Type: DiscussionPriority: NormalStatus: ActiveReplies: 1
#1

Hi, 

we are planning to implement monitoring feature for the increases in database size.

I did not find if there is some query for that.

Currently we are working on solution, that we simply read the size of filename directly from application. But in case of client-server use in future that would not be possible, is it achievable somehow?

Thank You

#2

This was implemented internally for the Explorer, but following this request, version 2.9.4 was released now and it supports getting the file size and the total number of entity objects by queries:

	try (EntityManagerFactory emf =
			Persistence.createEntityManagerFactory(dbPath)) {
		try (EntityManager em = emf.createEntityManager()) {
			long fileSize = em.createQuery(
				"objectdb file-size", Long.class).getSingleResult();
			System.out.printf("File Size: %d%n", fileSize);
			long objectCount = em.createQuery(
				"objectdb object-count", Long.class).getSingleResult();
			System.out.printf("Object Count: %d%n", objectCount);
		}
	}
ObjectDB Support

Reply