Returning the size of a record (in bytes) from OrientDB


OrientDB supports various methods to get the length of a collection or the length of a string, but I’m trying to determine the total size of a record in bytes. I can’t find anything in the documentation or elsewhere that addresses this. Is it possible?


Hi Eric,

ORecord class has a getSize() method, so the information is available (even though it’s not very accurate) at the API level.
This is not exposed in SQL, but I think we can do it in the near future




Interesting. What makes it “inaccurate”?

Should I open an issue on Github for this feature request?

In the mean time, I assume the only way to access it would be through Java? What about a Java function that could be called from SQL?


It is inaccurate in the sense that it returns an approximation based on the space used on disk by the record, but this space could not have been collected after you delete properties or you change property values (just to say one case).
Yes, it is available from Java, you can use a JS function to access it and use it in SQL




A JS function? That’s interesting. How to I access the getSize() method from JavaScript?


Just to give you an example:

and then use it in a query

select recordSize(@this) from v


Ah, OK. Easy enough. Thanks!