Loading...

verticapy.performance.vertica.qprof.QueryProfiler

class verticapy.performance.vertica.qprof.QueryProfiler(transactions: None | str | int | tuple | list[int] | list[tuple[int, int]] | list[str] = None, key_id: str | None = None, resource_pool: str | None = None, target_schema: None | str | dict = None, overwrite: bool = False, add_profile: bool = True, check_tables: bool = True, iterchecks: bool = False, print_info: bool = True)

Base class to profile queries.

Important

This class is currently under development and remains in beta. Please note that the parameters may undergo changes in the future. We plan to introduce a stable version in VerticaPy 1.0.3 or later.

Important

Most of the classes are not available in Version 1.0.0. Please use Version 1.0.1 or higher. Alternatively, you can use the help function to explore the functionalities of your current documentation.

The QueryProfiler is a valuable tool for anyone seeking to comprehend the reasons behind a query’s lack of performance. It incorporates a set of functions inspired by the original QPROF project, while introducing an enhanced feature set. This includes the capability to generate graphics and dashboards, facilitating a comprehensive exploration of the data.

Moreover, it offers greater convenience by allowing interaction with an object that encompasses various methods and expanded possibilities. To initiate the process, all that’s required is a transaction_id and a statement_id, or simply a query to execute.

Parameters

transactions: str | tuple | list, optional

Six options are possible for this parameter:

  • An integer:

    It will represent the transaction_id, the statement_id will be set to 1.

  • A tuple:

    (transaction_id, statement_id).

  • A list of tuples:

    (transaction_id, statement_id).

  • A list of integers:

    the transaction_id; the statement_id will automatically be set to 1.

  • A str:

    The query to execute.

  • A list of str:

    The list of queries to execute. Each query will be execute iteratively.

    Warning

    It’s important to exercise caution; if the query is time-consuming, it will require a significant amount of time to execute before proceeding to the next steps.

Note

A combination of the three first options can also be used in a list.

key_id: int, optional

This parameter is utilized to load information from another target_schema. It is considered a good practice to save the queries you intend to profile.

resource_pool: str, optional

Specify the name of the resource pool to utilize when executing the query. Refer to the Vertica documentation for a comprehensive list of available options.

Note

This parameter is used only when request is defined.

target_schema: str | dict, optional

Name of the schemas to use to store all the Vertica monitor and internal meta-tables. It can be a single schema or a dictionary of schema used to map all the Vertica DC tables. If the tables do not exist, VerticaPy will try to create them automatically.

overwrite: bool, optional

If set to True overwrites the existing performance tables.

add_profile: bool, optional

If set to True and the request does not include a profile, this option adds the profile keywords at the beginning of the query before executing it.

Note

This parameter is used only when request is defined.

check_tables: bool, optional

If set to True all the transactions of the different Performance tables will be checked and a warning will be raised in case of incomplete data.

Warning

This parameter will aggregate on many tables using many parameters. It will make the process much more expensive.

iterchecks: bool, optional

If set to True, the checks are done iteratively instead of using a unique SQL query. Usually checks are faster when this parameter is set to False.

Note

This parameter is used only when check_tables is True.

Attributes

transactions: list

list of tuples: (transaction_id, statement_id). It includes all the transactions of the current schema.

requests: list

list of str: Transactions Queries.

request_labels: list

list of str: Queries Labels.

qdurations: list

list of int: Queries Durations (seconds).

key_id: int

Unique ID used to build up the different Performance tables savings.

request: str

Current Query.

qduration: int

Current Query Duration (seconds).

transaction_id: int

Current Transaction ID.

statement_id: int

Current Statement ID.

target_schema: dict

Name of the schema used to store all the Vertica monitor and internal meta-tables.

target_tables: dict

Name of the tables used to store all the Vertica monitor and internal meta-tables.

v_tables_dtypes: list

Datatypes of all the performance tables.

tables_dtypes: list

Datatypes of all the loaded performance tables.

overwrite: bool

If set to True overwrites the existing performance tables.

Examples

Initialization

First, let’s import the QueryProfiler object.

from verticapy.performance.vertica import QueryProfiler

There are multiple ways how we can use the QueryProfiler.

  • From transaction_id and statement_id

  • From SQL generated from verticapy functions

  • Directly from SQL query

Transaction ID and Statement ID

In this example, we run a groupby command on the amazon dataset.

First, let us import the dataset:

from verticapy.datasets import load_amazon

amazon = load_amazon()

Then run the command:

query = amazon.groupby(
    columns = ["date"],
    expr = ["MONTH(date) AS month, AVG(number) AS avg_number"],
)

For every command that is run, a query is logged in the query_requests table. We can use this table to fetch the transaction_id and statement_id. In order to access this table we can use SQL Magic.

%load_ext verticapy.sql
%%sql
SELECT *
FROM query_requests
WHERE request LIKE '%avg_number%';

Hint

Above we use the WHERE command in order to filter only those results that match our query above. You can use these filters to sift through the list of queries.

Once we have the transaction_id and statement_id we can directly use it:

qprof = QueryProfiler((45035996273800581, 48))

Important

To save the different performance tables in a specific schema use target_schema='MYSCHEMA', ‘MYSCHEMA’ being the targetted schema. To overwrite the tables, use: overwrite=True. Finally, if you just need local temporary table, use the v_temp_schema schema.

Example:

qprof = QueryProfiler(
    (45035996273800581, 48),
    target_schema='v_temp_schema',
    overwrite=True,
)

Multiple Transactions ID and Statements ID

You can also construct an object based on multiple transactions and statement IDs by using a list of transactions and statements.

qprof = QueryProfiler(
    [(tr1, st2), (tr2, st2), (tr3, st3)],
    target_schema='MYSCHEMA',
    overwrite=True,
)

A key_id will be generated, which you can then use to reload the object.

qprof = QueryProfiler(
    key_id='MYKEY',
    target_schema='MYSCHEMA',
)

You can access all the transactions of a specific schema by utilizing the ‘transactions’ attribute.

qprof.transactions

SQL generated from VerticaPy functions

In this example, we can use the Titanic dataset:

from verticapy.datasets import load_titanic

titanic= load_titanic()

Let us run a simple command to get the average values of the two columns:

titanic["age","fare"].mean()

We can use the current_relation attribute to extract the generated SQL and this can be directly input to the Query Profiler:

qprof = QueryProfiler(
    "SELECT * FROM " + titanic["age","fare"].fillna().current_relation()
)

Directly From SQL Query

The last and most straight forward method is by directly inputting the SQL to the Query Profiler:

qprof = QueryProfiler(
    "select transaction_id, statement_id, request, request_duration"
    " from query_requests where start_timestamp > now() - interval'1 hour'"
    " order by request_duration desc limit 10;"
)

Searching the performance tables...
Setting the requests and queries durations...
Checking all the tables consistency using a single SQL query...
Checking all the tables data types...

The query is then executed, and you can easily retrieve the statement and transaction IDs.

tid = qprof.transaction_id

sid = qprof.statement_id

print(f"tid={tid};sid={sid}")
tid=45035996275851310;sid=2

Or simply:

print(qprof.transactions)
[(45035996275851310, 2)]

To avoid recomputing a query, you can also directly use its statement ID and its transaction ID.

qprof = QueryProfiler((tid, sid))
Searching the performance tables...
Setting the requests and queries durations...
Checking all the tables consistency using a single SQL query...
Checking all the tables data types...

Accessing the different Performance Tables

We can easily look at any Vertica Performance Tables easily:

qprof.get_table('dc_requests_issued')
📅
time
Timestamptz(35)
Abc
node_name
Varchar(128)
Abc
session_id
Varchar(128)
123
user_id
Integer
Abc
user_name
Varchar(128)
123
transaction_id
Integer
123
statement_id
Integer
123
request_id
Integer
Abc
request_type
Varchar(128)
Abc
label
Varchar(128)
Abc
Varchar(64000)
Abc
Varchar(64000)
123
query_start_epoch
Integer
Abc
Varchar(64000)
010
is_retry
Boolean
123
digest
Integer
12024-08-08 16:42:51.347633+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin450359962758440762768734QUERYverticapy_json153759
-2739771977645684132
22024-08-08 16:42:51.373739+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin450359962758440762868735QUERY153759
1173375758661070897
32024-08-08 16:42:51.397080+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin450359962758440762968736QUERYget_data_types153759
-6803372202362044141
42024-08-08 16:42:51.437976+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin450359962758440763068737QUERYverticapy_json153759
-2739771977645684132
52024-08-08 16:42:51.459713+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin450359962758440763168738QUERY_version153759
8903476768692993780
62024-08-08 16:42:51.482054+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin450359962758440763268739QUERYvDataframe.train_test_split153759
-6060496486953227029
72024-08-08 16:42:51.510432+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin450359962758440763368740QUERYverticapy_json153759
-2739771977645684132
82024-08-08 16:42:51.533256+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin450359962758440763468741QUERY153759
6814844219549955390
92024-08-08 16:42:51.557521+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin450359962758440763568742QUERYverticapy_json153759
-2739771977645684132
102024-08-08 16:42:51.579922+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin450359962758440763668743QUERY153759
6266927469521968618
112024-08-08 16:42:51.607922+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin450359962758440763768744QUERY_version153759
8903476768692993780
122024-08-08 16:42:51.631732+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin450359962758440763868745QUERYverticapy_json153759
-2739771977645684132
132024-08-08 16:42:51.650471+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin450359962758440763968746QUERY153759
7011138784295650856
142024-08-08 16:42:51.669162+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin450359962758440764068747QUERY_version153759
8903476768692993780
152024-08-08 16:42:51.691807+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin450359962758440764168748QUERYlearn.tools._is_already_stored153759
5835180282835082858
162024-08-08 16:42:51.734866+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin450359962758440764268749QUERY153759
7011138784295650856
172024-08-08 16:42:51.754923+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin450359962758440764368750QUERY153759
7011138784295650856
182024-08-08 16:42:51.777708+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin45035996275844120168751DDL153759
[null]
192024-08-08 16:42:51.781022+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin45035996275844120-168752UTILITYlearn.VerticaModel.fit153759
[null]
202024-08-08 16:42:51.785874+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin45035996275844123168753QUERY153759
-5861902804668782526
212024-08-08 16:42:51.826198+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin45035996275844125168754QUERY153759
8988585509947565202
222024-08-08 16:42:51.855476+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin0-168755UTILITY153759
[null]
232024-08-08 16:42:51.871969+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin45035996275844129168756QUERY153760
-4278133178688953219
242024-08-08 16:42:51.904913+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin45035996275844131168757QUERY153760
-4021881530365329931
252024-08-08 16:42:51.924520+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin0-168758UTILITY153760
[null]
262024-08-08 16:42:51.964319+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin45035996275844136168759QUERY153761
-5861036256698212095
272024-08-08 16:42:51.994613+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin45035996275844138168760DDL153761
[null]
282024-08-08 16:42:51.997126+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin45035996275844139168761QUERY_version153761
8903476768692993780
292024-08-08 16:42:52.018692+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin45035996275844139268762QUERY153761
4841572230508595135
302024-08-08 16:42:52.041354+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin45035996275844139368763QUERY_version153761
8903476768692993780
312024-08-08 16:42:52.064245+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin45035996275844139468764QUERYlearn.VerticaModel.__repr__153761
-8887346284077529213
322024-08-08 16:42:52.091399+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin45035996275844139568765QUERY_version153761
8903476768692993780
332024-08-08 16:42:52.114547+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin45035996275844139668766QUERY153761
8041259019814449157
342024-08-08 16:42:52.146857+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin45035996275844139768767QUERY_version153761
8903476768692993780
352024-08-08 16:42:52.172339+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin45035996275844139868768QUERY153761
4841572230508595135
362024-08-08 16:42:52.288546+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin45035996275844139968769QUERYverticapy_json153761
-2739771977645684132
372024-08-08 16:42:52.311794+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin450359962758441391068770QUERYverticapy_json153761
-2739771977645684132
382024-08-08 16:42:52.336719+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin450359962758441391168771QUERY153761
1173375758661070897
392024-08-08 16:42:52.360927+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin450359962758441391268772QUERYget_data_types153761
-6803372202362044141
402024-08-08 16:42:52.393517+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin450359962758441391368773QUERYverticapy_json153761
-2739771977645684132
412024-08-08 16:42:52.416613+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin450359962758441391468774QUERY_version153761
8903476768692993780
422024-08-08 16:42:52.440423+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin450359962758441391568775QUERYvDataframe.train_test_split153761
-6060496486953227029
432024-08-08 16:42:52.464766+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin450359962758441391668776QUERYverticapy_json153761
-2739771977645684132
442024-08-08 16:42:52.487590+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin450359962758441391768777QUERY153761
6814844219549955390
452024-08-08 16:42:52.508775+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin450359962758441391868778QUERYverticapy_json153761
-2739771977645684132
462024-08-08 16:42:52.530915+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin450359962758441391968779QUERY153761
6266927469521968618
472024-08-08 16:42:52.559617+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin450359962758441392068780QUERY_version153761
8903476768692993780
482024-08-08 16:42:52.582031+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin450359962758441392168781QUERYverticapy_json153761
-2739771977645684132
492024-08-08 16:42:52.602737+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin450359962758441392268782QUERY153761
7011138784295650856
502024-08-08 16:42:52.628084+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin450359962758441392368783QUERYlearn.tools._is_already_stored153761
5835180282835082858
512024-08-08 16:42:52.675301+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin450359962758441392468784QUERY153761
7011138784295650856
522024-08-08 16:42:52.697800+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin450359962758441392568785QUERY153761
7011138784295650856
532024-08-08 16:42:52.720967+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin45035996275844165168786DDL153761
[null]
542024-08-08 16:42:52.725299+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin45035996275844165-168787UTILITYlearn.VerticaModel.fit153761
[null]
552024-08-08 16:42:52.730882+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin45035996275844168168788QUERY153761
-8430327111529963382
562024-08-08 16:42:52.762960+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin0-168789UTILITY153761
[null]
572024-08-08 16:42:52.783698+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin45035996275844172168790QUERY153762
101314740696625926
582024-08-08 16:42:52.825274+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin45035996275844174168791QUERY153762
6493630772050899526
592024-08-08 16:42:52.854059+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin0-168792UTILITY153762
[null]
602024-08-08 16:42:52.870820+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin45035996275844178168793QUERY153763
-1032109414052218166
612024-08-08 16:42:52.926383+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin0-168794UTILITY153763
[null]
622024-08-08 16:42:52.942136+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin45035996275844182168795QUERY153764
2595799903314186095
632024-08-08 16:42:52.961319+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin0-168796UTILITY153764
[null]
642024-08-08 16:42:52.975021+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin45035996275844186168797QUERY153765
-1630482069323377711
652024-08-08 16:42:52.995428+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin0-168798UTILITY153765
[null]
662024-08-08 16:42:53.188897+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin45035996275844190168799QUERY153766
-5861036256698212095
672024-08-08 16:42:53.224381+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin45035996275844192168800QUERY153766
-5861036256698212095
682024-08-08 16:42:53.260141+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin45035996275844194168801DDL153766
[null]
692024-08-08 16:42:53.263005+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin45035996275844195168802QUERYlearn.VerticaModel.fit153766
-7938121625303578740
702024-08-08 16:42:53.293309+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin45035996275844195268803QUERY_version153766
8903476768692993780
712024-08-08 16:42:53.317776+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin45035996275844195368804QUERY153766
806487162735703196
722024-08-08 16:42:53.336041+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin45035996275844195468805QUERY_version153766
8903476768692993780
732024-08-08 16:42:53.362156+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin45035996275844195568806QUERY153766
806487162735703196
742024-08-08 16:42:53.394421+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin45035996275844195668807QUERY_version153766
8903476768692993780
752024-08-08 16:42:53.420513+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin45035996275844195768808QUERY153766
806487162735703196
762024-08-08 16:42:53.454063+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin45035996275844195868809QUERY_version153766
8903476768692993780
772024-08-08 16:42:53.481144+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin45035996275844195968810QUERY153766
806487162735703196
782024-08-08 16:42:53.514634+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin450359962758441951068811QUERY_version153766
8903476768692993780
792024-08-08 16:42:53.536197+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin450359962758441951168812QUERY153766
806487162735703196
802024-08-08 16:42:53.563473+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin450359962758441951268813QUERY_version153766
8903476768692993780
812024-08-08 16:42:53.584998+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin450359962758441951368814QUERY153766
806487162735703196
822024-08-08 16:42:53.611726+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin450359962758441951468815QUERY_version153766
8903476768692993780
832024-08-08 16:42:53.634334+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin450359962758441951568816QUERY153766
806487162735703196
842024-08-08 16:42:53.660155+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin450359962758441951668817QUERY_version153766
8903476768692993780
852024-08-08 16:42:53.682203+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin450359962758441951768818QUERY153766
806487162735703196
862024-08-08 16:42:53.709312+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin450359962758441951868819QUERY_version153766
8903476768692993780
872024-08-08 16:42:53.730732+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin450359962758441951968820QUERY153766
806487162735703196
882024-08-08 16:42:53.757355+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin450359962758441952068821QUERY_version153766
8903476768692993780
892024-08-08 16:42:53.781431+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin450359962758441952168822QUERY153766
806487162735703196
902024-08-08 16:42:53.813594+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin450359962758441952268823QUERY_version153766
8903476768692993780
912024-08-08 16:42:53.837248+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin450359962758441952368824QUERYlearn.VerticaModel.__repr__153766
-8887346284077529213
922024-08-08 16:42:53.904002+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin450359962758441952468825QUERYverticapy_json153766
-2739771977645684132
932024-08-08 16:42:53.926976+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin450359962758441952568826QUERYverticapy_json153766
-2739771977645684132
942024-08-08 16:42:53.948661+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin450359962758441952668827QUERY153766
1173375758661070897
952024-08-08 16:42:53.972131+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin450359962758441952768828QUERYget_data_types153766
-6803372202362044141
962024-08-08 16:42:54.006605+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin450359962758441952868829QUERYverticapy_json153766
-2739771977645684132
972024-08-08 16:42:54.027828+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin450359962758441952968830QUERY_version153766
8903476768692993780
982024-08-08 16:42:54.048318+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin450359962758441953068831QUERYvDataframe.train_test_split153766
-6060496486953227029
992024-08-08 16:42:54.072171+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin450359962758441953168832QUERYverticapy_json153766
-2739771977645684132
1002024-08-08 16:42:54.092802+00:00v_demo_node0001v_demo_node0001-145:0x1317245035996273704962dbadmin450359962758441953268833QUERY153766
6814844219549955390
Rows: 1-100 | Columns: 16

Note

You can use the method without parameters to obtain a list of all available tables.

qprof.get_table()
Out[8]: 
['dc_requests_issued',
 'dc_explain_plans',
 'dc_query_executions',
 'dc_plan_activities',
 'dc_scan_events',
 'dc_slow_events',
 'execution_engine_profiles',
 'host_resources',
 'query_events',
 'query_plan_profiles',
 'query_profiles',
 'projection_storage',
 'projection_usage',
 'resource_pool_status',
 'storage_containers',
 'dc_lock_attempts',
 'dc_plan_resources',
 'configuration_parameters',
 'query_consumption',
 'projections',
 'projection_columns',
 'resource_acquisitions',
 'resource_pools']

We can also look at all the object queries information:

qprof.get_queries()
010
is_current
Boolean
123
transaction_id
Integer
123
statement_id
Integer
Abc
request_label
Varchar
Abc
Varchar(179)
123
qduration
Numeric(9)
📅
start_timestamp
Timestamp(29)
📅
end_timestamp
Timestamp(29)
0
4503599627585131028.4093642024-08-08 16:45:36.6084972024-08-08 16:45:45.012267
Rows: 1-1 | Columns: 9

Executing a QPROF step

Numerous QPROF steps are accessible by directly using the corresponding methods. For instance, step 0 corresponds to the Vertica version, which can be executed using the associated method get_version.

qprof.get_version()
Out[9]: (23, 4, 0, 0)

Note

To explore all available methods, please refer to the ‘Methods’ section. For additional information, you can also utilize the help function.

It is possible to access the same step by using the step method.

qprof.step(idx = 0)
Out[10]: (23, 4, 0, 0)

Note

By changing the idx value above, you can check out all the steps of the QueryProfiler.

SQL Query

SQL query can be conveniently reproduced in a color formatted version:

qprof.get_request()

Query Performance Details

Query Execution Time

To get the execution time of the entire query:

qprof.get_qduration(unit="s")
Out[11]: 8.409364

Note

You can change the unit to “m” to get the result in minutes.

Query Execution Time Plots

To get the time breakdown of all the steps in a graphical output, we can call the get_qsteps attribute.

qprof.get_qsteps(kind="bar")
Loading....

Note

The same plot can also be plotted using a bar plot by setting kind='bar'.

Note

For charts, it is possible to pass many parameters to customize them. Example: You can use categoryorder to sort the chart or width and height to manage the size.

Query Plan

To get the entire query plan:

qprof.get_qplan()
+-SELECT  LIMIT 10 [Cost: 592K, Rows: 10 (NO STATISTICS)] (PATH ID: 0)
|  Output Only: 10 tuples
| +---> SORT [TOPK] [Cost: 592K, Rows: 10K (NO STATISTICS)] (PATH ID: 1)
| |      Order: query_requests.request_duration DESC
| |      Output Only: 10 tuples
| | +---> JOIN HASH [LeftOuter] [Cost: 9K, Rows: 10K (NO STATISTICS)] (PATH ID: 3)
| | |      Join Cond: (ri.node_name = dc_requests_completed.node_name) AND (ri.session_id = dc_requests_completed.session_id) AND (ri.request_id = dc_requests_completed.request_id)
| | |      Materialize at Output: ri."time", ri.transaction_id, ri.statement_id, ri.request
| | | +-- Outer -> STORAGE ACCESS for ri [Cost: 3K, Rows: 10K (NO STATISTICS)] (PATH ID: 4)
| | | |      Projection: v_internal.dc_requests_issued_p
| | | |      Materialize: ri.node_name, ri.session_id, ri.request_id
| | | |      Filter: (ri."time" > '2024-08-08 15:45:36.599122+00'::timestamptz)
| | | +-- Inner -> STORAGE ACCESS for dc_requests_completed [Cost: 4K, Rows: 10K (NO STATISTICS)] (PATH ID: 5)
| | | |      Projection: v_internal.dc_requests_completed_p
| | | |      Materialize: dc_requests_completed.request_id, dc_requests_completed."time", dc_requests_completed.node_name, dc_requests_completed.session_id
| | | |      Filter: (dc_requests_completed.node_name IS NOT NULL)
| | | |      Filter: (dc_requests_completed.session_id IS NOT NULL)
| | | |      Filter: (dc_requests_completed.request_id IS NOT NULL)
Out[12]: '+-SELECT  LIMIT 10 [Cost: 592K, Rows: 10 (NO STATISTICS)] (PATH ID: 0)\n|  Output Only: 10 tuples\n| +---> SORT [TOPK] [Cost: 592K, Rows: 10K (NO STATISTICS)] (PATH ID: 1)\n| |      Order: query_requests.request_duration DESC\n| |      Output Only: 10 tuples\n| | +---> JOIN HASH [LeftOuter] [Cost: 9K, Rows: 10K (NO STATISTICS)] (PATH ID: 3)\n| | |      Join Cond: (ri.node_name = dc_requests_completed.node_name) AND (ri.session_id = dc_requests_completed.session_id) AND (ri.request_id = dc_requests_completed.request_id)\n| | |      Materialize at Output: ri."time", ri.transaction_id, ri.statement_id, ri.request\n| | | +-- Outer -> STORAGE ACCESS for ri [Cost: 3K, Rows: 10K (NO STATISTICS)] (PATH ID: 4)\n| | | |      Projection: v_internal.dc_requests_issued_p\n| | | |      Materialize: ri.node_name, ri.session_id, ri.request_id\n| | | |      Filter: (ri."time" > \'2024-08-08 15:45:36.599122+00\'::timestamptz)\n| | | +-- Inner -> STORAGE ACCESS for dc_requests_completed [Cost: 4K, Rows: 10K (NO STATISTICS)] (PATH ID: 5)\n| | | |      Projection: v_internal.dc_requests_completed_p\n| | | |      Materialize: dc_requests_completed.request_id, dc_requests_completed."time", dc_requests_completed.node_name, dc_requests_completed.session_id\n| | | |      Filter: (dc_requests_completed.node_name IS NOT NULL)\n| | | |      Filter: (dc_requests_completed.session_id IS NOT NULL)\n| | | |      Filter: (dc_requests_completed.request_id IS NOT NULL)'

Query Plan Tree

We can easily call the function to get the query plan Graphviz:

qprof.get_qplan_tree(return_graphviz = True)
Out[13]: 'digraph Tree {\n\tgraph [bgcolor="#FFFFFFDD"]\n\tnode [shape=plaintext, fillcolor=white]\tedge [color="#000000", style=solid];\n\tlegend_annotations [shape=plaintext, fillcolor=white, label=<<table border="0" cellborder="1" cellspacing="0"><tr><td BGCOLOR="#DFDFDF"></td><td BGCOLOR="#DFDFDF"><FONT COLOR="#000000">Path transition</FONT></td></tr><tr><td BGCOLOR="#DFDFDF"><FONT COLOR="#000000">🚫</FONT></td><td BGCOLOR="#FFFFFFDD"><FONT COLOR="#000000">NO STATISTICS</FONT></td></tr><tr><td BGCOLOR="#DFDFDF"><FONT COLOR="#000000">H</FONT></td><td BGCOLOR="#FFFFFFDD"><FONT COLOR="#000000">HASH</FONT></td></tr><tr><td BGCOLOR="#DFDFDF"><FONT COLOR="#000000">O</FONT></td><td BGCOLOR="#FFFFFFDD"><FONT COLOR="#000000">OUTER</FONT></td></tr><tr><td BGCOLOR="#DFDFDF"><FONT COLOR="#000000">I</FONT></td><td BGCOLOR="#FFFFFFDD"><FONT COLOR="#000000">INNER</FONT></td></tr></table>>]\n\n\n\tlegend0 [shape=plaintext, fillcolor=white, label=<<table border="0" cellborder="1" cellspacing="0"><tr><td BGCOLOR="#DFDFDF"><FONT COLOR="#000000">Execution time in µs</FONT></td></tr><tr><td BGCOLOR="#00FF00"><FONT COLOR="#000000">0</FONT></td></tr><tr><td BGCOLOR="#3FBF00"><FONT COLOR="#000000">6</FONT></td></tr><tr><td BGCOLOR="#7F7F00"><FONT COLOR="#000000">47</FONT></td></tr><tr><td BGCOLOR="#BF3F00"><FONT COLOR="#000000">328</FONT></td></tr><tr><td BGCOLOR="#FF0000"><FONT COLOR="#000000">2K</FONT></td></tr></table>>]\n\n\tlegend1 [shape=plaintext, fillcolor=white, label=<<table border="0" cellborder="1" cellspacing="0"><tr><td BGCOLOR="#DFDFDF"><FONT COLOR="#000000">Produced row count</FONT></td></tr><tr><td BGCOLOR="#00FF00"><FONT COLOR="#000000">20</FONT></td></tr><tr><td BGCOLOR="#3FBF00"><FONT COLOR="#000000">342</FONT></td></tr><tr><td BGCOLOR="#7F7F00"><FONT COLOR="#000000">6K</FONT></td></tr><tr><td BGCOLOR="#BF3F00"><FONT COLOR="#000000">92K</FONT></td></tr><tr><td BGCOLOR="#FF0000"><FONT COLOR="#000000">2M</FONT></td></tr></table>>]\n\n\t0 [width=1.22, height=1.22, tooltip="SELECT  LIMIT 10 [Cost: 592K, Rows: 10 (NO STATISTICS)] (PATH ID: 0)\n\nAggregated metrics:\n---------------------\n\n - Execution time in µs: 0.035\n - Estimated row count: 20\n - Processed row count: 0\n - Produced row count: 20\n - Produced RLE row count: 20\n - Network consumer stall time in µs: 0\n - Network producer stall time in µs: 0\n - Clock time in µs: 35\n - Reserved memory size in MB: 0.2\n - Allocated memory size in MB: 0\n - Number of bytes spilled: 0\n - Execution time in µs: 0.035\n - Produced row count: 20\n\nMetrics per operator\n---------------------\n\nExprEval:\n - Execution time in µs: 0.018\n - Estimated row count: 10\n - Processed row count: 0\n - Produced row count: 10\n - Produced RLE row count: 10\n - Network consumer stall time in µs: 0\n - Network producer stall time in µs: 0\n - Clock time in µs: 17\n - Reserved memory size in MB: 0.1\n - Allocated memory size in MB: 0\n - Number of bytes spilled: 0\n\nTopK:\n - Execution time in µs: 0.017\n - Estimated row count: 10\n - Processed row count: 0\n - Produced row count: 10\n - Produced RLE row count: 10\n - Network consumer stall time in µs: 0\n - Network producer stall time in µs: 0\n - Clock time in µs: 18\n - Reserved memory size in MB: 0.1\n - Allocated memory size in MB: 0\n - Number of bytes spilled: 0\n\nDescriptors\n------------\n\nOutput Only: 10 tuples", fixedsize=true, URL="#path_id=0", xlabel="🚫", label=<<TABLE border="1" cellborder="1" cellspacing="0" cellpadding="0"><TR><TD WIDTH="18.0" HEIGHT="36.0" BGCOLOR="#00FF00" ><FONT COLOR="#00FF00">.</FONT></TD><TD WIDTH="18.0" HEIGHT="36.0" BGCOLOR="#FFFFFFDD"><FONT POINT-SIZE="22.0" COLOR="#000000">0</FONT></TD><TD WIDTH="18.0" HEIGHT="36.0" BGCOLOR="#FFFFFFDD"><FONT POINT-SIZE="22.0" COLOR="#000000">🔍</FONT></TD><TD WIDTH="18.0" HEIGHT="36.0" BGCOLOR="#00FF00"><FONT COLOR="#00FF00">.</FONT></TD></TR></TABLE>>];\n\t1 [width=1.22, height=1.22, tooltip="SORT [TOPK] [Cost: 592K, Rows: 10K (NO STATISTICS)] (PATH ID: 1)\n\nAggregated metrics:\n---------------------\n\n - Execution time in µs: 243.762\n - Estimated row count: 9,999\n - Processed row count: 0\n - Produced row count: 95,378\n - Produced RLE row count: 95,378\n - Network consumer stall time in µs: 0\n - Network producer stall time in µs: 0\n - Clock time in µs: 220,897\n - Reserved memory size in MB: 0.9\n - Allocated memory size in MB: 0\n - Number of bytes spilled: 0\n - Execution time in µs: 243.762\n - Produced row count: 95,378\n\nMetrics per operator\n---------------------\n\nExprEval:\n - Execution time in µs: 148.686\n - Estimated row count: 0\n - Processed row count: 0\n - Produced row count: 95,368\n - Produced RLE row count: 95,368\n - Network consumer stall time in µs: 0\n - Network producer stall time in µs: 0\n - Clock time in µs: 149,094\n - Reserved memory size in MB: 0.1\n - Allocated memory size in MB: 0\n - Number of bytes spilled: 0\n\nTopK:\n - Execution time in µs: 95.076\n - Estimated row count: 9,999\n - Processed row count: 0\n - Produced row count: 10\n - Produced RLE row count: 10\n - Network consumer stall time in µs: 0\n - Network producer stall time in µs: 0\n - Clock time in µs: 71,803\n - Reserved memory size in MB: 0.8\n - Allocated memory size in MB: 0\n - Number of bytes spilled: 0\n\nDescriptors\n------------\n\nOrder: query_requests.request_duration DESC\n\nOutput Only: 10 tuples", fixedsize=true, URL="#path_id=1", xlabel="🚫", label=<<TABLE border="1" cellborder="1" cellspacing="0" cellpadding="0"><TR><TD WIDTH="18.0" HEIGHT="36.0" BGCOLOR="#B54900" ><FONT COLOR="#B54900">.</FONT></TD><TD WIDTH="18.0" HEIGHT="36.0" BGCOLOR="#FFFFFFDD"><FONT POINT-SIZE="22.0" COLOR="#000000">1</FONT></TD><TD WIDTH="18.0" HEIGHT="36.0" BGCOLOR="#FFFFFFDD"><FONT POINT-SIZE="22.0" COLOR="#000000">🔀</FONT></TD><TD WIDTH="18.0" HEIGHT="36.0" BGCOLOR="#C03E00"><FONT COLOR="#C03E00">.</FONT></TD></TR></TABLE>>];\n\t3 [width=1.22, height=1.22, tooltip="JOIN HASH [LeftOuter] [Cost: 9K, Rows: 10K (NO STATISTICS)] (PATH ID: 3)\n\nAggregated metrics:\n---------------------\n\n - Execution time in µs: 2,249.615\n - Estimated row count: 9,999\n - Processed row count: 0\n - Produced row count: 190,736\n - Produced RLE row count: 190,736\n - Network consumer stall time in µs: 0\n - Network producer stall time in µs: 0\n - Clock time in µs: 1,055,960\n - Reserved memory size in MB: 8.4\n - Allocated memory size in MB: 0\n - Number of bytes spilled: 0\n - Execution time in µs: 2,249.615\n - Produced row count: 190,736\n\nMetrics per operator\n---------------------\n\nJoin:\n - Execution time in µs: 889.985\n - Estimated row count: 9,999\n - Processed row count: 0\n - Produced row count: 95,368\n - Produced RLE row count: 95,368\n - Network consumer stall time in µs: 0\n - Network producer stall time in µs: 0\n - Clock time in µs: 1,055,960\n - Reserved memory size in MB: 0\n - Allocated memory size in MB: 0\n - Number of bytes spilled: 0\n\nStorageUnion:\n - Execution time in µs: 1,359.63\n - Estimated row count: 0\n - Processed row count: 0\n - Produced row count: 95,368\n - Produced RLE row count: 95,368\n - Network consumer stall time in µs: 0\n - Network producer stall time in µs: 0\n - Clock time in µs: 0\n - Reserved memory size in MB: 8.4\n - Allocated memory size in MB: 0\n - Number of bytes spilled: 0\n\nDescriptors\n------------\n\nJoin Cond: (ri.node_name = dc_requests_completed.node_name) AND (ri.session_id = dc_requests_completed.session_id) AND (ri.request_id = dc_requests_completed.request_id)\n\nMaterialize at Output: ri.\'time\', ri.transaction_id, ri.statement_id, ri.request", fixedsize=true, URL="#path_id=3", xlabel="🚫", label=<<TABLE border="1" cellborder="1" cellspacing="0" cellpadding="0"><TR><TD WIDTH="18.0" HEIGHT="36.0" BGCOLOR="#FF0000" ><FONT COLOR="#FF0000">.</FONT></TD><TD WIDTH="18.0" HEIGHT="36.0" BGCOLOR="#FFFFFFDD"><FONT POINT-SIZE="22.0" COLOR="#000000">3</FONT></TD><TD WIDTH="18.0" HEIGHT="36.0" BGCOLOR="#FFFFFFDD"><FONT POINT-SIZE="22.0" COLOR="#000000">🔗</FONT></TD><TD WIDTH="18.0" HEIGHT="36.0" BGCOLOR="#CF2F00"><FONT COLOR="#CF2F00">.</FONT></TD></TR></TABLE>>];\n\t4 [width=1.22, height=1.22, tooltip="Outer -> STORAGE ACCESS for ri [Cost: 3K, Rows: 10K (NO STATISTICS)] (PATH ID: 4)\n\nAggregated metrics:\n---------------------\n\n - Execution time in µs: 11.628\n - Estimated row count: 9,999\n - Processed row count: 109,494\n - Produced row count: 95,368\n - Produced RLE row count: 95,368\n - Network consumer stall time in µs: 0\n - Network producer stall time in µs: 0\n - Clock time in µs: 12,046\n - Reserved memory size in MB: 0\n - Allocated memory size in MB: 0\n - Number of bytes spilled: 0\n - Execution time in µs: 11.628\n - Produced row count: 95,368\n\nMetrics per operator\n---------------------\n\nScan:\n - Execution time in µs: 11.628\n - Estimated row count: 9,999\n - Processed row count: 109,494\n - Produced row count: 95,368\n - Produced RLE row count: 95,368\n - Network consumer stall time in µs: 0\n - Network producer stall time in µs: 0\n - Clock time in µs: 12,046\n - Reserved memory size in MB: 0\n - Allocated memory size in MB: 0\n - Number of bytes spilled: 0\n\nDescriptors\n------------\n\nProjection: v_internal.dc_requests_issued_p\n\nMaterialize: ri.node_name, ri.session_id, ri.request_id\n\nFilter: (ri.\'time\' > \'2024-08-08 15:45:36.599122+00\'::timestamptz)", fixedsize=true, URL="#path_id=4", xlabel="🚫", label=<<TABLE border="1" cellborder="1" cellspacing="0" cellpadding="0"><TR><TD WIDTH="18.0" HEIGHT="36.0" BGCOLOR="#53AB00" ><FONT COLOR="#53AB00">.</FONT></TD><TD WIDTH="18.0" HEIGHT="36.0" BGCOLOR="#FFFFFFDD"><FONT POINT-SIZE="22.0" COLOR="#000000">4</FONT></TD><TD WIDTH="18.0" HEIGHT="36.0" BGCOLOR="#FFFFFFDD"><FONT POINT-SIZE="22.0" COLOR="#000000">🗄️</FONT></TD><TD WIDTH="18.0" HEIGHT="36.0" BGCOLOR="#C03E00"><FONT COLOR="#C03E00">.</FONT></TD></TR><TR><TD COLSPAN="4" WIDTH="18.0" HEIGHT="36.0" BGCOLOR="#FFFFFFDD" ><FONT POINT-SIZE="9.0" COLOR="#000000">v_interna..</FONT></TD></TR></TABLE>>];\n\t5 [width=1.22, height=1.22, tooltip="Inner -> STORAGE ACCESS for dc_requests_completed [Cost: 4K, Rows: 10K (NO STATISTICS)] (PATH ID: 5)\n\nAggregated metrics:\n---------------------\n\n - Execution time in µs: 547.269\n - Estimated row count: 9,997\n - Processed row count: 752,791\n - Produced row count: 1,505,582\n - Produced RLE row count: 1,505,582\n - Network consumer stall time in µs: 0\n - Network producer stall time in µs: 0\n - Clock time in µs: 140,804\n - Reserved memory size in MB: 4.7\n - Allocated memory size in MB: 0\n - Number of bytes spilled: 0\n - Execution time in µs: 547.269\n - Produced row count: 1,505,582\n\nMetrics per operator\n---------------------\n\nScan:\n - Execution time in µs: 131.469\n - Estimated row count: 9,997\n - Processed row count: 752,791\n - Produced row count: 752,791\n - Produced RLE row count: 752,791\n - Network consumer stall time in µs: 0\n - Network producer stall time in µs: 0\n - Clock time in µs: 140,804\n - Reserved memory size in MB: 0\n - Allocated memory size in MB: 0\n - Number of bytes spilled: 0\n\nStorageUnion:\n - Execution time in µs: 415.8\n - Estimated row count: 0\n - Processed row count: 0\n - Produced row count: 752,791\n - Produced RLE row count: 752,791\n - Network consumer stall time in µs: 0\n - Network producer stall time in µs: 0\n - Clock time in µs: 0\n - Reserved memory size in MB: 4.7\n - Allocated memory size in MB: 0\n - Number of bytes spilled: 0\n\nDescriptors\n------------\n\nProjection: v_internal.dc_requests_completed_p\n\nMaterialize: dc_requests_completed.request_id, dc_requests_completed.\'time\', dc_requests_completed.node_name, dc_requests_completed.session_id\n\nFilter: (dc_requests_completed.node_name IS NOT NULL)\n\nFilter: (dc_requests_completed.session_id IS NOT NULL)\n\nFilter: (dc_requests_completed.request_id IS NOT NULL)", fixedsize=true, URL="#path_id=5", xlabel="🚫", label=<<TABLE border="1" cellborder="1" cellspacing="0" cellpadding="0"><TR><TD WIDTH="18.0" HEIGHT="36.0" BGCOLOR="#D02E00" ><FONT COLOR="#D02E00">.</FONT></TD><TD WIDTH="18.0" HEIGHT="36.0" BGCOLOR="#FFFFFFDD"><FONT POINT-SIZE="22.0" COLOR="#000000">5</FONT></TD><TD WIDTH="18.0" HEIGHT="36.0" BGCOLOR="#FFFFFFDD"><FONT POINT-SIZE="22.0" COLOR="#000000">🗄️</FONT></TD><TD WIDTH="18.0" HEIGHT="36.0" BGCOLOR="#FF0000"><FONT COLOR="#FF0000">.</FONT></TD></TR><TR><TD COLSPAN="4" WIDTH="18.0" HEIGHT="36.0" BGCOLOR="#FFFFFFDD" ><FONT POINT-SIZE="9.0" COLOR="#000000">v_interna..</FONT></TD></TR></TABLE>>];\n\n\t0 -> 1 [dir=back, label="  ", style=solid, fontcolor="#000000"];\n\t1 -> 3 [dir=back, label="  ", style=solid, fontcolor="#000000"];\n\t3 -> 4 [dir=back, label=" O ", style=solid, fontcolor="#000000"];\n\t3 -> 5 [dir=back, label=" I-H ", style=solid, fontcolor="#000000"];\n\n}'

We can conveniently get the Query Plan tree:

qprof.get_qplan_tree()
Tree legend_annotations Path transition 🚫 NO STATISTICS H HASH O OUTER I INNER legend0 Execution time in µs 0 6 47 328 2K legend1 Produced row count 20 342 6K 92K 2M 0 . 0 🔍 . 🚫 1 . 1 🔀 . 🚫 0->1   3 . 3 🔗 . 🚫 1->3   4 . 4 🗄️ . v_interna.. 🚫 3->4 O 5 . 5 🗄️ . v_interna.. 🚫 3->5 I-H

We can easily customize the tree:

qprof.get_qplan_tree(
    metric='cost',
    shape='square',
    color_low='#0000FF',
    color_high='#FFC0CB',
)
Tree legend_annotations Path transition 🚫 NO STATISTICS H HASH O OUTER I INNER legend0 Query plan cost 3K 11K 42K 158K 592K 0 . 0 🔍 🚫 1 . 1 🔀 🚫 0->1   3 . 3 🔗 🚫 1->3   4 . 4 🗄️ v_interna.. 🚫 3->4 O 5 . 5 🗄️ v_interna.. 🚫 3->5 I-H

We can look at a specific path ID, and look at some specific paths information:

qprof.get_qplan_tree(
    path_id=1,
    path_id_info=[1, 3],
    metric='cost',
    shape='square',
    color_low='#0000FF',
    color_high='#FFC0CB',
)
Tree legend_annotations Path transition 🚫 NO STATISTICS H HASH O OUTER I INNER legend0 Query plan cost 3K 11K 42K 158K 592K 0 . 0 🔍 🚫 1 . 1 🔀 🚫 0->1   3 . 3 🔗 🚫 1->3   7 SORT [TOPK] [Cost: 592K, Rows: 10K (NO STATISTICS)] (PATH ID: 1)  Order: query_requests.requ est_duration DESC  Output Only: 10 tuples  Aggregated metrics: --------------------- - Execution time in µs: 243.762  - Estimated row count: 9,999  - Processed row count: 0  - Produced row count: 95,378  - Produced RLE row count: 95,378  - Network consumer stall time in µs: 0 - Network producer stall time in µs: 0  - Clock time in µs: 220,897  - Reserved memory size in MB: 0.9  - Allocated memory size in MB: 0  - Number of bytes spilled: 0  - Query plan cost: 592,000  Metrics per operator --------------------- ExprEval:  - Execution time in µs: 148.686  - Estimated row count: 0  - Processed row count: 0  - Produced row count: 95,368  - Produced RLE row count: 95,368  - Network consumer stall time in µs: 0 - Network producer stall time in µs: 0  - Clock time in µs: 149,094  - Reserved memory size in MB: 0.1  - Allocated memory size in MB: 0  - Number of bytes spilled: 0  TopK:  - Execution time in µs: 95.076 - Estimated row count: 9,999 - Processed row count: 0  - Produced row count: 10  - Produced RLE row count: 10  - Network consumer stall time in µs: 0  - Network producer stall time in µs: 0  - Clock time in µs: 71,803  - Reserved memory size in MB: 0.8  - Allocated memory size in MB: 0 - Number of bytes spilled: 0 7->1 4 . 4 🗄️ v_interna.. 🚫 3->4 O 5 . 5 🗄️ v_interna.. 🚫 3->5 I-H 9 JOIN HASH [LeftOuter] [Cost: 9K, Rows: 10K (NO STATISTICS)] (PATH ID: 3)  Join Cond: (ri.node_name = dc_requests_co mpleted.node_name) AND (ri.session_id = dc_requests_c ompleted.session_id) AND (ri.request_id = dc_requests_c ompleted.request_id) Materialize at Output: ri.'time', ri.transaction_id, ri.statement_id, ri.request Aggregated metrics: ---------------------   - Execution time in µs: 2,249.615  - Estimated row count: 9,999  - Processed row count: 0  - Produced row count: 190,736  - Produced RLE row count: 190,736  - Network consumer stall time in µs: 0 - Network producer stall time in µs: 0  - Clock time in µs: 1,055,960  - Reserved memory size in MB: 8.4  - Allocated memory size in MB: 0  - Number of bytes spilled: 0  - Query plan cost: 9,000  Metrics per operator --------------------- Join:  - Execution time in µs: 889.985  - Estimated row count: 9,999  - Processed row count: 0  - Produced row count: 95,368  - Produced RLE row count: 95,368  - Network consumer stall time in µs: 0 - Network producer stall time in µs: 0  - Clock time in µs: 1,055,960  - Reserved memory size in MB: 0  - Allocated memory size in MB: 0  - Number of bytes spilled: 0 StorageUnion:  - Execution time in µs: 1,359.63  - Estimated row count: 0  - Processed row count: 0  - Produced row count: 95,368  - Produced RLE row count: 95,368 - Network consumer stall time in µs: 0  - Network producer stall time in µs: 0  - Clock time in µs: 0  - Reserved memory size in MB: 8.4  - Allocated memory size in MB: 0 - Number of bytes spilled: 0 9->3

Query Plan Profile

To visualize the time consumption of query profile plan:

qprof.get_qplan_profile(kind = "pie")

Note

The same plot can also be plotted using a bar plot by switching the kind to “bar”.

Query Events

We can easily look at the query events:

qprof.get_query_events()
📅
event_timestamp
Timestamptz(35)
Abc
node_name
Varchar(128)
Abc
event_category
Varchar(12)
Abc
event_type
Varchar(64000)
Abc
event_description
Varchar(64000)
Abc
operator_name
Varchar(128)
123
path_id
Integer
Abc
event_details
Varchar(64000)
Abc
suggested_action
Varchar(64000)
Rows: 0 | Columns: 9

CPU Time by Node and Path ID

Another very important metric could be the CPU time spent by each node. This can be visualized by:

qprof.get_cpu_time(kind="bar")

In order to get the results in a tabular form, just switch the show option to False.

qprof.get_cpu_time(show=False)
Abc
node_name
Varchar(128)
Abc
path_id
Varchar(20)
123
counter_value
Integer
1v_demo_node0001-159
2v_demo_node0001-182
3v_demo_node0001017
4v_demo_node0001018
5v_demo_node0001195076
6v_demo_node00011148686
7v_demo_node000131359630
8v_demo_node00012413115
9v_demo_node00013889985
10v_demo_node0001411628
11v_demo_node00015415800
12v_demo_node00015131469
Rows: 1-12 | Columns: 3

Resource Acquisition Report

To obtain a comprehensive resource acquisition report, including specific details such as queue_wait_time, pool_name… utilize the following syntax:

qprof.get_resource_acquisition()
Abc
node_name
Varchar(128)
Abc
operator_name
Varchar(128)
123
path_id
Integer
123
exec_time_us
Numeric(38)
123
est_rows
Integer
123
proc_rows
Integer
123
prod_rows
Integer
123
rle_prod_rows
Integer
123
cstall_us
Integer
123
pstall_us
Integer
123
clock_time_us
Integer
123
mem_res_mb
Numeric(38)
123
mem_all_mb
Numeric(38)
123
bytes_spilled
Integer
1v_demo_node0001Join3889.9859999[null]9536895368[null][null]1055960[null][null][null]
2v_demo_node0001ExprEval2413.1159999[null]9536895368[null][null]4589302.2[null][null]
3v_demo_node0001Scan411.62899991094949536895368[null][null]120460.0[null][null]
4v_demo_node0001TopK195.0769999[null]1010[null][null]718030.8[null][null]
5v_demo_node0001Scan5131.4699997752791752791752791[null][null]1408040.0[null][null]
6v_demo_node0001ExprEval00.01810[null]1010[null][null]170.1[null][null]
7v_demo_node0001TopK00.01710[null]1010[null][null]180.1[null][null]
8v_demo_node0001ExprEval1148.686[null][null]9536895368[null][null]1490940.1[null][null]
9v_demo_node0001StorageUnion5415.8[null][null]752791752791[null][null][null]4.7[null][null]
10v_demo_node0001StorageUnion31359.63[null][null]9536895368[null][null][null]8.4[null][null]
11v_demo_node0001Root-10.059[null][null]10[null][null][null]60[null][null][null]
12v_demo_node0001NewEENode-10.082[null][null]1010[null][null]830.4[null][null]
Rows: 1-12 | Columns: 14

Query Execution Report

To obtain a comprehensive performance report, including specific details such as which node executed each operation and the corresponding timing information, utilize the following syntax:

qprof.get_qexecution_report()
Abc
node_name
Varchar(128)
Abc
operator_name
Varchar(128)
123
path_id
Integer
123
exec_time_us
Numeric(38)
123
est_rows
Integer
123
proc_rows
Integer
123
prod_rows
Integer
123
rle_prod_rows
Integer
123
cstall_us
Integer
123
pstall_us
Integer
123
clock_time_us
Integer
123
mem_res_mb
Numeric(38)
123
mem_all_mb
Numeric(38)
123
bytes_spilled
Integer
1v_demo_node0001TopK195.0769999[null]1010[null][null]718030.8[null][null]
2v_demo_node0001Join3889.9859999[null]9536895368[null][null]1055960[null][null][null]
3v_demo_node0001ExprEval2413.1159999[null]9536895368[null][null]4589302.2[null][null]
4v_demo_node0001Scan411.62899991094949536895368[null][null]120460.0[null][null]
5v_demo_node0001Scan5131.4699997752791752791752791[null][null]1408040.0[null][null]
6v_demo_node0001ExprEval00.01810[null]1010[null][null]170.1[null][null]
7v_demo_node0001TopK00.01710[null]1010[null][null]180.1[null][null]
8v_demo_node0001StorageUnion31359.63[null][null]9536895368[null][null][null]8.4[null][null]
9v_demo_node0001NewEENode-10.082[null][null]1010[null][null]830.4[null][null]
10v_demo_node0001Root-10.059[null][null]10[null][null][null]60[null][null][null]
11v_demo_node0001ExprEval1148.686[null][null]9536895368[null][null]1490940.1[null][null]
12v_demo_node0001StorageUnion5415.8[null][null]752791752791[null][null][null]4.7[null][null]
Rows: 1-12 | Columns: 14

Query Activity Time Report

To obtain a comprehensive report including Elapsed, exec_time and I/O by node, activity & path_id, utilize the following syntax:

qprof.get_activity_time()
Abc
node_name
Varchar(128)
123
path_id
Integer
Abc
activity
Varchar(1024)
Abc
abl_id
Varchar(62)
123
elaps_us
Integer
123
exec_us
Integer
Abc
Varchar(1024)
123
input_rows
Integer
123
input_mb
Numeric(38)
123
proc_rows
Integer
123
proc_mb
Numeric(38)
1v_demo_node0001-1Send Data to Client1000,0,026959[null][null][null][null]
2v_demo_node00010Unused1011,3,324718[null][null][null][null]
3v_demo_node00010TopK1012,2,224517[null][null][null][null]
4v_demo_node00011Unused1008,5,54543625148686[null][null][null][null]
5v_demo_node00011TopK HEAP1009,4,4454362395076[null][null][null][null]
6v_demo_node00011Emit TopK1010,4,4258[null][null][null][null][null]
7v_demo_node00012Evaluate Expressions1006,7,74588090413115[null][null][null][null]
8v_demo_node00013Build Join Inner1004,8,81766300[null][null][null][null][null]
9v_demo_node00013Join (hash)1005,8,84588151889985[null][null][null][null]
10v_demo_node00013Combine Storage Chunks1007,6,6454362713596300[null][null][null]
11v_demo_node00013reserveVTLoaderResources1013,6,6[null][null][null][null][null][null]
12v_demo_node00014Scan Projection1003,9,9458818011628[null][null]109494[null]
13v_demo_node00015Scan Projection1001,11,111105122131469[null][null]752791[null]
14v_demo_node00015Combine Storage Chunks1002,10,1011049584158000[null][null][null]
15v_demo_node00015reserveVTLoaderResources1014,10,10[null][null][null][null][null][null]
Rows: 1-15 | Columns: 11

Projection Data Distribution

To obtain the projection data distribution, utilize the following syntax:

qprof.get_proj_data_distrib()
Abc
table_name
Varchar(257)
Abc
projection_name
Varchar(128)
Abc
node_name
Varchar(128)
123
row_count
Integer
123
used_bytes
Integer
123
ROS_count
Integer
123
del_rows
Integer
123
DV_count
Integer
Rows: 0 | Columns: 8

Note

This report is really useful to check if the data are correctly segmented.

Node/Cluster Information

Nodes

To get node-wise performance information, get_qexecution can be used:

qprof.get_qexecution()

Note

To use one specific node:

qprof.get_qexecution(
    node_name = "v_vdash_node0003",
    metric = "exec_time_us",
    kind = "pie",
)

To use multiple nodes:

qprof.get_qexecution(
    node_name = [
        "v_vdash_node0001",
        "v_vdash_node0003",
    ],
    metric = "exec_time_us",
    kind = "pie",
)

The node name is different for different configurations. You can search for the node names in the full report.

Cluster

To get cluster configuration details, we can use:

qprof.get_cluster_config()
Abc
host_name
Varchar(128)
123
open_files_limit
Integer
123
threads_limit
Integer
123
core_file_limit_max_size_bytes
Integer
123
processor_count
Integer
123
processor_core_count
Integer
Abc
Varchar(8192)
123
opened_file_count
Integer
123
opened_socket_count
Integer
123
opened_nonfile_nonsocket_count
Integer
123
total_memory_bytes
Integer
123
total_memory_free_bytes
Integer
123
total_buffer_memory_bytes
Integer
123
total_memory_cache_bytes
Integer
123
total_swap_memory_bytes
Integer
123
total_swap_memory_free_bytes
Integer
123
disk_space_free_mb
Integer
123
disk_space_used_mb
Integer
123
disk_space_total_mb
Integer
123
system_open_files
Integer
123
system_max_files
Integer
1127.0.0.11048576255422012061010334855987201373644390431503564858090987528589934592858993459295382277195103101838809223372036854775807
Rows: 1-1 | Columns: 21

The Cluster Report can also be conveniently extracted:

qprof.get_rp_status()
Abc
node_name
Varchar(128)
123
pool_oid
Integer
Abc
pool_name
Varchar(128)
010
is_internal
Boolean
123
memory_size_kb
Integer
123
memory_size_actual_kb
Integer
123
memory_inuse_kb
Integer
123
general_memory_borrowed_kb
Integer
123
queueing_threshold_kb
Integer
123
max_memory_size_kb
Integer
123
max_query_memory_size_kb
Integer
123
running_query_count
Integer
123
planned_concurrency
Integer
123
max_concurrency
Integer
010
is_standalone
Boolean
📅
queue_timeout
Interval day to second
123
queue_timeout_in_seconds
Integer
Abc
execution_parallelism
Varchar(128)
123
priority
Integer
Abc
runtime_priority
Varchar(128)
123
runtime_priority_threshold
Integer
123
runtimecap_in_seconds
Integer
Abc
single_initiator
Varchar(128)
123
query_budget_kb
Integer
Abc
cpu_affinity_set
Varchar(256)
Abc
cpu_affinity_mask
Varchar(1024)
Abc
cpu_affinity_mode
Varchar(128)
1v_demo_node000145035996273705004general
2467453824674538002344081024674538[null]013[null]
relativedelta(minutes=+5)300AUTO0MEDIUM2[null]false1803139fffffANY
2v_demo_node000145035996273705006sysquery
104857610485764034802463133225927718[null]113[null]
relativedelta(minutes=+5)300AUTO110HIGH0[null]false80659fffffANY
3v_demo_node000145035996273705008tm
31457283145728002662362628024870[null]077
relativedelta(minutes=+5)300AUTO105MEDIUM60[null]true449389fffffANY
4v_demo_node000145035996273705010refresh
00002363518424879142[null]04[null]
relativedelta(minutes=+5)300AUTO-10MEDIUM60[null]true5860202fffffANY
5v_demo_node000145035996273705012recovery
00002363518424879142[null]02211
relativedelta(minutes=+5)300AUTO107MEDIUM60[null]true1065491fffffANY
6v_demo_node000145035996273705014dbd
00002363518424879142[null]04[null]
relativedelta()0AUTO0MEDIUM0[null]true5860202fffffANY
7v_demo_node000145035996273705092jvm
000019922942097152[null]013[null]
relativedelta(minutes=+5)300AUTO0MEDIUM2[null]false153253fffffANY
8v_demo_node000145035996273705102blobdata
000027619762907344[null]020
relativedelta()0AUTO0HIGH0[null]false[null]fffffANY
9v_demo_node000145035996273705104metadata
204604204604002363518424879142[null]010
relativedelta()0AUTO108HIGH0[null]false[null]fffffANY
Rows: 1-9 | Columns: 27

Important

Each method may have multiple parameters and options. It is essential to refer to the documentation of each method to understand its usage.

__init__(transactions: None | str | int | tuple | list[int] | list[tuple[int, int]] | list[str] = None, key_id: str | None = None, resource_pool: str | None = None, target_schema: None | str | dict = None, overwrite: bool = False, add_profile: bool = True, check_tables: bool = True, iterchecks: bool = False, print_info: bool = True) None

Methods

__init__([transactions, key_id, ...])

export_profile(filename)

The export_profile() method provides a high-level interface for creating an export bundle of parquet files from a QueryProfiler instance.

get_activity_time()

Returns the a report including: Elapsed, exec_time and I/O by node, activity & path_id.

get_cluster_config()

Returns the Cluster configuration.

get_cpu_time([kind, reverse, categoryorder, ...])

Returns the CPU Time by node and path_id chart.

get_proj_data_distrib()

Returns the Projection Data Distribution.

get_qduration([unit])

Returns the Query duration.

get_qexecution([node_name, metric, path_id, ...])

Returns the Query execution chart.

get_qexecution_report()

Returns the Query execution report.

get_qplan([return_report, print_plan])

Returns the Query Plan chart.

get_qplan_explain([display_trees])

Returns the tree's query explain plan as a list of titles and trees.

get_qplan_profile([unit, kind, ...])

Returns the Query Plan chart.

get_qplan_tree([path_id, path_id_info, ...])

Draws the Query Plan tree.

get_qsteps([unit, kind, categoryorder, show])

Returns the Query Execution Steps chart.

get_queries()

Returns all the queries and their respective information, of a QueryProfiler object.

get_query_events()

Returns a :py:class`vDataFrame` that contains a table listing query events.

get_request([indent_sql, print_sql, return_html])

Returns the query linked to the object with the specified transaction ID and statement ID.

get_resource_acquisition()

Returns the a report including the resource acquisition.

get_rp_status()

Returns the RP status.

get_table([table_name])

Returns the associated Vertica Table.

get_version()

Returns the current Vertica version.

import_profile(target_schema, key_id, filename)

The static method import_profile can be used to create new QueryProfiler object from the contents of a export bundle.

insert(transactions)

Functions to insert new transactions to the copy of the performance tables.

next()

A utility function to utilize the next transaction from the QueryProfiler stack.

previous()

A utility function to utilize the previous transaction from the QueryProfiler stack.

set_position(idx)

A utility function to utilize a specific transaction from the QueryProfiler stack.

step(idx, *args, **kwargs)

Function to return the QueryProfiler Step.

to_html([path])

Creates an HTML report.