Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I display the query time when a query completes in Vertica?

Tags:

sql

vertica

vsql

When using vsql, I would like to see how long a query took to run once it completes. For example when i run:

select count(distinct key) from schema.table;

I would like to see an output like:

5678
(1 row)
total query time: 55 seconds.

If this is not possible, is there another way to measure query time?

like image 453
Ilya Kaplun Avatar asked Jul 20 '11 18:07

Ilya Kaplun


People also ask

How do you check query execution time?

Using Client StatisticsGo to Menu >> Query >> Select Include client Statistics. Execute your query. In the results panel, you can see a new tab Client Statistics. Go to the Client Statistics tab to see the execution time.

What is query in time?

In query time mode, imported data is joined with hit data when a report requests (queries for) the data. As a result, the imported data can be joined to both historical hits as well as to hits received after the data is uploaded. Custom reports and unsampled reports can access data imported using Query time mode.


2 Answers

In vsql type:

\timing 

and then hit Enter. You'll like what you'll see :-)

Repeating that will turn it off.

like image 123
Igor Avatar answered Oct 12 '22 03:10

Igor


Regarding the other part of your question:

is there another way to measure query time?

Vertica can log a history of all queries executed on the cluster which is another source of query time. Before 6.0 the relevant system table was QUERY_REPO, starting with 6.0 it is QUERY_REQUESTS.

Assuming you're on 6.0 or higher, QUERY_REQUESTS.REQUEST_DURATION_MS will give you the query duration in milliseconds.

Example of how you might use QUERY_REQUESTS:

    select *
    from query_requests
    where request_type = 'QUERY'
    and user_name = 'dbadmin'
    and start_timestamp >= CURRENT_DATE
    and request ilike 'select%from%schema.table%'
    order by start_timestamp;

The QUERY_PROFILES.QUERY_DURATION_US and RESOURCE_ACQUISITIONS.DURATION_MS columns may also be of interest to you. Here are the short descriptions of those tables in case you're not already familiar:

RESOURCE_ACQUISITIONS - Retains information about resources (memory, open file handles, threads) acquired by each running request for each resource pool in the system.

QUERY_PROFILES - Provides information about queries that have run.

like image 38
dmarwick Avatar answered Oct 12 '22 02:10

dmarwick