Skip to main content

Calculate Request Queue Length

  • November 8, 2018
  • 6 replies
  • 13 views

Jim_Knicely
Forum|alt.badge.img+2

The RESOURCE_ACQUISITIONS system table retains information about resources (memory, open file handles, threads) acquired by each running request. Each request is uniquely identified by its transaction and statement IDs within a given session.

From this system table, you can calculate how long a request was queued in a resource pool before acquiring the resources it needed to execute from the difference between QUEUE_ENTRY_TIMESTAMP and ACQUISITION_TIMESTAMP.

Example:

I’d like to know if there were any requests in the GENERAL pool which queued longer than 1 second.

dbadmin=> SELECT node_name,
dbadmin->        request_type,
dbadmin->        transaction_id,
dbadmin->        statement_id,
dbadmin->        pool_name,
dbadmin->        (acquisition_timestamp - queue_entry_timestamp) request_queue_length
dbadmin->   FROM v_monitor.resource_acquisitions
dbadmin->  WHERE pool_name = 'general'
dbadmin->    AND (acquisition_timestamp - queue_entry_timestamp) > '1 second'
dbadmin->  ORDER BY (acquisition_timestamp - queue_entry_timestamp) DESC;
node_name | request_type | transaction_id | statement_id | pool_name | request_queue_length
-----------+--------------+----------------+--------------+-----------+----------------------
(0 rows)

There were none!

So which request in the GENERAL pool did queue the longest?

dbadmin=> SELECT node_name,
dbadmin->        request_type,
dbadmin->        transaction_id,
dbadmin->        statement_id,
dbadmin->        pool_name,
dbadmin->        (acquisition_timestamp - queue_entry_timestamp) request_queue_length
dbadmin->   FROM v_monitor.resource_acquisitions
dbadmin->  WHERE pool_name = 'general'
dbadmin->  ORDER BY (acquisition_timestamp - queue_entry_timestamp) DESC
dbadmin->  LIMIT 1;
     node_name      | request_type |  transaction_id   | statement_id | pool_name | request_queue_length
--------------------+--------------+-------------------+--------------+-----------+----------------------
v_test_db_node0001 | Reserve      | 45035996274412358 |            1 | general   | 00:00:00.000447
(1 row)

Helpful Link:
https://www.vertica.com/docs/9.1.x/HTML/index.htm#Authoring/SQLReferenceManual/SystemTables/MONITOR/RESOURCE_ACQUISITIONS.htm

Have fun!

6 replies

chaima
Forum|alt.badge.img+2
  • Participating Frequently
  • November 8, 2018

Many thanks for the tip Jim!
Is there a way to know the reason for which a query was queued? Something similar to what we have with RESOURCE_REJECTIONS


Jim_Knicely
Forum|alt.badge.img+2
  • Author
  • Participating Frequently
  • November 9, 2018

scottpedersoli
Forum|alt.badge.img+1
  • Participating Frequently
  • November 9, 2018

Great question chaima! Based on Jim's tip I'm now reviewing results of resource_acquisitions and do see queuing, wondering if/how i can dig deeper into root cause.


chaima
Forum|alt.badge.img+2
  • Participating Frequently
  • November 12, 2018

Many thanks @Jim_Knicely ! I was hoping to find a system table where we have the history of queued queries not the currently pending ones..


chaima
Forum|alt.badge.img+2
  • Participating Frequently
  • November 12, 2018

@emoreno does this mean that prior to 9.1SP1 we can have queue_wait>0 even if it's not the case if the query requires additionnal ressources?
Thank you


chaima
Forum|alt.badge.img+2
  • Participating Frequently
  • November 12, 2018

I was checking resource_acquisitions and the difference between acquisition_timestamp and queue_entry_timestamp columns,
I found the Jira for this issue
This is very helpful, many thanks Eugenia!
Chaima