server_processing_time() Method

Returns the elapsed server processing time.

Syntax

Cursor.server_processing_time()

Returns

The elapsed server processing time, in microseconds. This value does not include network communication time.

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 fetch server processing time for the first 32 rows. If fetching more rows requires additional fetch requests to the server, then the server processing time is a non-zero value and calculated from the beginning of the current result set.

Example

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 processing time from the INSERT statement:

processingTime = cursor.server_processing_time()

Example 2

Run the following SELECT statement:

cursor.execute("SELECT * FROM TEST_DIAG")
cursor.fetchall()

Run the following method to retrieve the fetch server processing time (not including the execute server processing time) from the SELECT statement:

processingTime = cursor.server_processing_time()