Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimize(cli): optimize the execution time format and omit to print time on empty query #514

Merged
merged 2 commits into from
Feb 22, 2022

Conversation

arkbriar
Copy link
Contributor

Signed-off-by: arkbriar arkbriar@gmail.com

close #510

Optimize the time format to be similar to pgcli, which prints the execution time in seconds with three precision numbers and also a human-readable duration in seconds when the duration is longer than 1 second.

Examples:

  1. Empty lines (no output)
> 
> 
> 
  1. In 1s (only duration in seconds)
select count(*) from lineitem;
+---------+
| count   |
+---------+
| 6001215 |
+---------+
in 0.186s
  1. Longer than 1s (with human-readable duration)
select
    l_returnflag,
    l_linestatus,
    sum(l_quantity) as sum_qty,
    sum(l_extendedprice) as sum_base_price,
    sum(l_extendedprice * (1 - l_discount)) as sum_disc_price,
    sum(l_extendedprice * (1 - l_discount) * (1 + l_tax)) as sum_charge,
    avg(l_quantity) as avg_qty,
    avg(l_extendedprice) as avg_price,
    avg(l_discount) as avg_disc,
    count(*) as count_order
from
    lineitem
where
    l_shipdate <= date '1998-12-01' - interval '71' day
group by
    l_returnflag,
    l_linestatus
order by
    l_returnflag,
    l_linestatus;
+--------------+--------------+----------+-----------------+-------------------+---------------------+--------------------------------+--------------------------------+--------------------------------+-------------+
| l_returnflag | l_linestatus | sum_qty  | sum_base_price  | sum_disc_price    | sum_charge          | avg_qty                        | avg_price                      | avg_disc                       | count_order |
+--------------+--------------+----------+-----------------+-------------------+---------------------+--------------------------------+--------------------------------+--------------------------------+-------------+
| A            | F            | 37734107 | 56586554400.73  | 53758257134.8700  | 55909065222.827692  | 25.522005853257337031693758442 | 38273.129734621672202709109884 | 0.0499852958383976116221043995 | 1478493     |
| N            | F            | 991417   | 1487504710.38   | 1413082168.0541   | 1469649223.194375   | 25.516471920522983476604725382 | 38284.467760848303906933649045 | 0.0500934266742162969063674268 | 38854       |
| N            | O            | 75283683 | 112909876769.66 | 107265890064.7416 | 111560462484.162066 | 25.500840389078803497319290943 | 38245.960228243034695434326354 | 0.0499965957637073860749460403 | 2952204     |
| R            | F            | 37719753 | 56568041380.90  | 53741292684.6040  | 55889619119.831932  | 25.505793612690770655973817847 | 38250.85462609965717067761196  | 0.0500094058301270564687903602 | 1478870     |
+--------------+--------------+----------+-----------------+-------------------+---------------------+--------------------------------+--------------------------------+--------------------------------+-------------+
in 5.888s (6s)
  1. Interrupted (no output)
> select
    l_returnflag,
    l_linestatus,
    sum(l_quantity) as sum_qty,
    sum(l_extendedprice) as sum_base_price,
    sum(l_extendedprice * (1 - l_discount)) as sum_disc_price,
    sum(l_extendedprice * (1 - l_discount) * (1 + l_tax)) as sum_charge,
    avg(l_quantity) as avg_qty,
    avg(l_extendedprice) as avg_price,
    avg(l_discount) as avg_disc,
    count(*) as count_order
from
    lineitem
where
    l_shipdate <= date '1998-12-01' - interval '71' day
group by
    l_returnflag,
    l_linestatus
order by
    l_returnflag,
    l_linestatus;
^CInterrupted
2022-02-21T11:57:20.018646Z  WARN risinglight::executor::table_scan: Abort!

…ime on empty query.

Signed-off-by: arkbriar <arkbriar@gmail.com>
Copy link
Collaborator

@TennyZhuang TennyZhuang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@skyzh skyzh enabled auto-merge (squash) February 22, 2022 12:05
@skyzh skyzh merged commit f9f9d58 into risinglightdb:main Feb 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cli: optimize the printed query time
3 participants