verticapy.performance.vertica.qprof.QueryProfiler.get_request#
- QueryProfiler.get_request(indent_sql: bool = True, print_sql: bool = True, return_html: bool = False) str #
Returns the query linked to the object with the specified transaction ID and statement ID.
Parameters#
- indent_sql: bool, optional
If set to true, indents the SQL code.
- print_sql: bool, optional
If set to true, prints the SQL code.
- return_html: bool, optional
If set to true, returns the query HTML code.
Returns#
- str
SQL query.
Examples#
First, let’s import the
QueryProfiler
object.from verticapy.performance.vertica import QueryProfiler
Then we can create a query:
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;" )
We can get the SQL query by:
qprof.get_request() <IPython.core.display.Markdown object> PROFILE 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 Out[1]: "PROFILE \n SELECT\n transaction_id,\n statement_id,\n request,\n request_duration \n FROM\n query_requests \n WHERE start_timestamp > NOW() - INTERVAL'1 hour' \n ORDER BY request_duration DESC \n LIMIT 10"
Note
For more details, please look at
QueryProfiler
.