getServerMemoryUsage() Method
Returns the server memory usage for the result set fetches.
Returns
The server memory usage for the result set fetches, in bytes.
Remarks
The returned value is for the fetches since the beginning of the current result set. If nextResult is called, then the returned results are reset for the new result set.
By default, executed statements include server memory usage for the first 32 rows. If fetching more rows requires additional fetch requests to the server, then the server memory usage value is a non-zero value and calculated from the beginning of the current result set.
getServerMemoryUsage() returns 0 if you are connected to an SAP HANA 2.0 SPS 03 server or earlier. It also returns 0 unless memory_tracking and resource_tracking is enabled in the resource_tracking section of global.ini by setting enable_tracking and memory_tracking to "on". For performance reasons, resource tracking is disabled by default.
Example
Ensure that monitoring is enabled in the resource_tracking section of global.ini by setting enable_tracking and memory_tracking to "on". For performance reasons, resource tracking is disabled by default.
Connect to the SAP HANA database:
var hana=require('@sap/hana-client');
var conn=hana.createConnection();
conn.connect("serverNode=myserver;uid=<user-id>;pwd=<password>");
Run the following statement with the getServerMemoryUsage method to retrieve the server memory usage for the fetch requests (not including the execute server memory usage):
var sql = "SELECT TOP 100 * FROM OBJECTS";
var stmt = conn.prepare(sql);
var result_set = stmt.execQuery();
var rows = [];
while (result_set.next()) {
rows.push(result_set.getValues());
}
var memoryUsage = result_set.getServerMemoryUsage();