【问题标题】:Finding summary & basic statistics from data in Vertica从 Vertica 中的数据中查找摘要和基本统计​​信息
【发布时间】:2017-08-22 06:43:07
【问题描述】:

最近我正在探索一下 HPE Vertica。是否可以从 vertica 中加载的数据表中找到汇总统计信息(平均值、标准差、四分位数、最大值、最小值、计数等)? 这两个链接; https://my.vertica.com/docs/7.0.x/HTML/Content/Authoring/SQLReferenceManual/Functions/VerticaFunctions/ANALYZE_STATISTICS.htm

https://my.vertica.com/docs/7.0.x/HTML/Content/Authoring/SQLReferenceManual/Functions/VerticaFunctions/ANALYZE_HISTOGRAM.htm

说我们可以从数据中找到统计数据和直方图,但结果对我来说毫无意义。

据此,ANALYZE_STATISTICS 命令将抛出 0 表示成功执行。喜欢

NEWDB_aug17=> SELECT ANALYZE_STATISTICS ('MM_schema.capitalline'); 
 ANALYZE_STATISTICS 
--------------------
                  0
(1 row)

这里 NEWDB_aug17 是数据库,schema 是 MM_schema,在其下插入了 capitalline 表。但是汇总措施在哪里,我的意思是我们实际寻找的数字?只有 0 不符合我的目的。

你能在这方面指导我吗?

【问题讨论】:

    标签: vertica summary


    【解决方案1】:

    Vertica 将 ANALYZE_STATISTICS() 收集的统计信息保存在目录位置。

    这些统计信息稍后用于计算最佳查询执行计划。

    您可以在系统表v_internal.dc_analyze_statistics

    中找到统计详情
    [dbadmin@vertica-1 ~]$ vsql
    dbadmin=> \x
    Expanded display is on.
    dbadmin=> select * from v_internal.dc_analyze_statistics limit 1;
    -[ RECORD 1 ]----+-----------------------------------
    time             | 2017-08-21 02:07:03.287895+00
    node_name        | v_test_node0001
    session_id       | v_test_node0001-502811:0x834a4
    user_id          | 45035996273704962
    user_name        | dbadmin
    transaction_id   | 45035996307673368
    statement_id     | 9
    request_id       | 1
    table_name       | test_table
    proj_column_name | test_column
    proj_name        | test_table_sp_v11_b1
    table_oid        | 45036013037102108
    proj_column_oid  | 45036013037111264
    proj_row_count   | 119878353211
    disk_percent     | 10
    disk_read_rows   | 11987835321
    sample_rows      | 131072
    sample_bytes     | 7602176
    start_time       | 2017-08-21 02:07:03.657377+00
    end_time         | 2017-08-21 02:07:24.799398+00
    
    Time: First fetch (1 row): 849.467 ms. All rows formatted: 849.594 ms
    

    或者在这个路径:

    {your_catalog_location}/{db_name}/{node_name}_catalog/DataCollector/AnalyzeStatistics_*.log
    

    【讨论】:

    • 感谢您的回复。但是结果只能以摘要的形式返回计数。我不能在合并视图中得到平均值、标准差、四分位数、最小值最大值吗?就像在 R 中,我们编写 summary(df) 或在 python 中我们编写 df.describe(),其中 df 是我的数据。
    • 如果没有第三方工具,您无法在 Vertica 中获取它。
    【解决方案2】:

    Vertica 的 percentile_cont 函数将有助于检索四分位数。

    create table test
    (metric_value integer);
    
    insert into test values(1);
    insert into test values(2);
    insert into test values(3);
    insert into test values(4);
    insert into test values(5);
    insert into test values(6);
    insert into test values(7);
    insert into test values(8);
    insert into test values(9);
    insert into test values(10);
    
    alter table anatest add column metric varchar(100) default 'abc';
    
    select
     metric_value,
     percentile_cont(1) within group (order by metric_value) over (partition by metric) as max,
     percentile_cont(.75) within group (order by metric_value ) over (partition by metric) as q3,
     percentile_cont(.5) within group (order by metric_value ) over (partition by metric) as median,
     percentile_cont(.25) within group (order by metric_value ) over (partition by metric) as q1,
     percentile_cont(0) within group (order by metric_value ) over (partition by metric) as min
     from test ;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多