
verticapy.performance.vertica.qprof_interface.QueryProfilerInterface.export_profile¶
- QueryProfilerInterface.export_profile(filename: PathLike) None ¶
The
export_profile()
method provides a high-level interface for creating an export bundle of parquet files from a QueryProfiler instance.- The export bundle is a tarball. Inside the tarball there are:
profile_meta.json
, a file with some information about
the other files in the tarball * Several
.parquet
files. There is one.parquet
for each system table that py:class:~verticapy.performance.vertica.qprof.QueryProfiler uses to analyze query performance. * For example, there is a file calleddc_requests_issued.parquet
.
Parameters¶
- filename: os.PathLike
The name of the export bundle to be produced. The input type is a synonym for a string or a
pathlib.Path
.
Returns¶
Returns None. Produces
filename
.Examples¶
First, let’s import the
QueryProfiler
object.from verticapy.performance.vertica import QueryProfiler from verticapy.performance.vertica.collection.profile_export import ProfileExport
Now we can profile a query and create a set of system table replicas by calling the
QueryProfiler
constructor: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;", target_schema="replica_001", key_id="example123" )
The parameter
target_schema
tells the QueryProfiler to create a set of replica tables. The parameterkey_id
specifies a suffix for all of the replica tables associated with this profile. The replica tables are a snapshot of the system tables. The replica tables are filtered to contain only the information relevant to the query that we have profiled.Now we can use
export_profile
to produce an export bundle. We choose to name our export bundle"query_requests_example_001.tar"
.qprof.export_profile(filename="query_requests_example_001.tar")
After producing an export bundle, we can examine the file contents using any tool that read tar-format files. For instance, we can use the tarfile library to print the names of all files in the tarball
tfile = tarfile.open("query_requests_example_001.tar") for f in tfile.getnames(): print(f"Tarball contains path: {f}")
The output will be:
Tarball contains path: dc_explain_plans.parquet, Tarball contains path: dc_query_executions.parquet ...