3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Teradataの統計情報

Last updated at Posted at 2020-08-29

特徴

Teradataの統計情報取得(初回)は表単位で取得することは出来ず、列単位で取得する必要があります。
再取得は表単位で指定可能です。その場合は、取得済の列に対して統計情報が再取得されます。

統計情報関連コマンド

実行内容 コマンド
統計情報取得(初回) COLLECT STATISTICS ON [表名] COLUMN [列名];
統計情報取得(初回)複数列 COLLECT STATISTICS ON [表名] COLUMN ([列名], [列名], …);
統計情報再取得 COLLECT STATISTICS ON [表名];
統計情報確認 HELP STATISTICS [表名];
統計情報確認 SELECT * FROM dbc.TableStatsV WHERE TableName = '[表名]';

実行例

統計情報確認

HELP STATISTICS t1;

 *** Help information returned. 6 rows.
 *** Total elapsed time was 1 second.

Date     Time     Unique Values        Column Names
-------- -------- -------------------- -----------------------------------------------------------------------------------------------------------------------------------------------------------------
20/08/29 12:14:06            4,194,309 *
20/08/29 12:11:34            4,194,309 c1
20/08/29 12:11:56                    1 c2
20/08/29 12:12:23                    1 c3
20/08/29 12:13:21                    1 c4,c5
20/08/29 12:14:06                    1 c6,c7

select ColumnName, RowCount, UniqueValueCount, BLCCompRatio from dbc.TableStatsV where TableName = 't1';

 *** Query completed. 6 rows found. 4 columns returned. 
 *** Total elapsed time was 1 second.

ColumnName
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
               RowCount
   --------------------
       UniqueValueCount
   --------------------
     BLCCompRatio
   --------------
c6,c7
              4,194,309
                      1
                ?
c4,c5
              4,194,309
                      1
                ?
?
              4,194,309
                      ?
               79
c2
              4,194,309
                      1
                ?
c3
              4,194,309
                      1
                ?
c1
              4,194,309
              4,194,309
                ?

参考

[統計文 • Teradata Vantage™ SQLデータ定義言語 構文規則および例 • リーダー • Teradataドキュメント]
(https://www.docs.teradata.com/reader/RknaJAFX_2CtUAZfB4_rTA/_9F6XXJ30kKl0hxcnLLpMQ)
[TableStatsV • Teradata Vantage™ データ ディクショナリ • リーダー • Teradataドキュメント]
(https://docs.teradata.com/reader/fMqp0D_uNdzh8~BHZ2S~9w/OSyWI~ERlUsaXLjEjRlPAw)

3
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?