server_memory_usage() Method
Returns the server memory usage.
Syntax
Cursor.server_memory_usage()
Returns
The server memory usage, in bytes.
Remarks
If the cursor is executed but not fetched, then the returned value is only for the most recent execution. If the cursor is fetched, then the returned value is for the fetches since the beginning of the most recent result set. If nextset is called, then the returned value is for the new result set.
By default, the execution includes the memory usage for the first 32 rows. If fetching more rows requires additional fetch requests to the server, then the fetch memory usage is a non-zero value and calculated from the beginning of the current result set.
server_memory_usage() returns 0 if you are connected to an SAP HANA 2.0 SPS 03 server or earlier or 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.
Create the following table:
cursor = conn.cursor()
cursor.execute("CREATE TABLE TEST_DIAG (A INTEGER PRIMARY KEY)")
Example 1
Run the following INSERT statement:
cursor.execute("INSERT INTO TEST_DIAG VALUES(?)", (123))
Run the following method to retrieve the server memory usage from the INSERT statement:
memoryUsage = cursor.server_memory_usage()
Example 2
Run the following SELECT statement:
cursor.execute("SELECT * FROM TEST_DIAG")
cursor.fetchall()
Run the following method to retrieve the fetch server memory usage (not including the execute server memory usage) from the SELECT statement:
memoryUsage = cursor.server_memory_usage()