关于oushudb-hawq:OushuDB-查看查询执行情况

4次阅读

共计 2531 个字符,预计需要花费 7 分钟才能阅读完成。

应用 \timing 命令能够打印出查问执行的工夫。

 test=# \timing on
 Timing is on.

 test=# select * from foo; # 这时再执行 SQL 语句会给出语句执行工夫。id | name
 ----+------
   1 | hawq
   2 | hdfs
 (2 rows)

 Time: 16.369 ms

 test=# \timing off  # 敞开工夫输入
 Timing is off.

 应用 explain 语句能够显示出查问打算。test=# explain select count(*) from foo;
                                     QUERY PLAN
----------------------------------------------------------
  Aggregate  (cost=1.07..1.08 rows=1 width=8)
    ->  Gather Motion 1:1  (slice1; segments: 1)  (cost=1.03..1.06 rows=1 width=8)
      ->  Aggregate  (cost=1.03..1.04 rows=1 width=8)
            ->  Append-only Scan on foo  (cost=0.00..1.02 rows=2 width=0)
  Settings:  default_hash_table_bucket_number=6
 (5 rows)

应用 explain analyze 能够显示出查问在具体执行时的状态,包含每一个操作符开始执行工夫,以及完结工夫,能够帮忙用户找到查问的瓶颈,进而优化查问。对于查问打算以及 explain analyze 的执行后果的解释能够参考查问打算与查问执行章节。针对一个查问,可能会有无数个查问打算。得出优化的查问打算是查问优化器的性能。一个查问执行工夫的长短与查问的打算有很大关系,所以相熟查问打算以及具体查问的执行对查问优化有很大意义。

 test=# explain analyze select count(*) from foo;
 -----------------------------------------------------------
Aggregate  (cost=1.07..1.08 rows=1 width=8)
Rows out:  Avg 1.0 rows x 1 workers.  Max/Last(seg-1:changlei/seg-1:changlei) 1/1 rows with 5.944/5.944 ms to end, start offset by 6.568/6.568 ms.
->  Gather Motion 1:1  (slice1; segments: 1)  (cost=1.03..1.06 rows=1 width=8)
      Rows out:  Avg 1.0 rows x 1 workers at destination.  Max/Last(seg-1:changlei/seg-1:changlei) 1/1 rows with 5.941/5.941 ms to first row, 5.942/5.942 ms to end, start offset by 6.569/6.569 ms.
      ->  Aggregate  (cost=1.03..1.04 rows=1 width=8)
            Rows out:  Avg 1.0 rows x 1 workers.  Max/Last(seg0:changlei/seg0:changlei) 1/1 rows with 5.035/5.035 ms to first row, 5.036/5.036 ms to end, start offset by 7.396/7.396 ms.
            ->  Append-only Scan on foo  (cost=0.00..1.02 rows=2 width=0)
                  Rows out:  Avg 2.0 rows x 1 workers.  Max/Last(seg0:changlei/seg0:changlei) 2/2 rows with 5.011/5.011 ms to first row, 5.032/5.032 ms to end, start offset by 7.397/7.397 ms.
Slice statistics:
  (slice0)    Executor memory: 223K bytes.
  (slice1)    Executor memory: 279K bytes (seg0:changlei).
Statement statistics:
  Memory used: 262144K bytes
Settings:  default_hash_table_bucket_number=6
Dispatcher statistics:
  executors used(total/cached/new connection): (1/1/0); dispatcher time(total/connection/dispatch data): (1.462 ms/0.000 ms/0.029 ms).
  dispatch data time(max/min/avg): (0.029 ms/0.029 ms/0.029 ms); consume executor data time(max/min/avg): (0.012 ms/0.012 ms/0.012 ms); free executor time(max/min/avg): (0.000 ms/0.000 ms/0.000 ms).
Data locality statistics:
  data locality ratio: 1.000; virtual segment number: 1; different host number: 1; virtual segment number per host(avg/min/max): (1/1/1); segment size(avg/min/max): (56.000 B/56 B/56 B); segment size with penalty(avg/min/max): (56.000 B/56 B/56 B); continuity(avg/min/max): (1.000/1.000/1.000); DFS metadatacache: 0.049 ms; resource allocation: 0.612 ms; datalocality calculation: 0.085 ms.
Total runtime: 13.398 ms
(20 rows)
正文完
 0