159
外匯
Deepgreen(Greenplum) DBA常用運維SQL
1.查看對象大小(表、索引、數據庫等)
select pg_size_pretty(pg_relation_size(’$schema.$table’));
示例:
tpch=# select pg_size_pretty(pg_relation_size('public.customer'));
pg_size_pretty
----------------
122 MB
(1 row)
2.查看用戶(非係統)表和索引
tpch=# select * from pg_stat_user_tables;
relid | schemaname | relname | seq_scan | seq_tup_read | idx_scan | idx_tup_fetch | n_tup_ins | n_tup_upd | n_tup_del | last_vacuum | last_autovacuum | last_analyze
| last_autoanalyze
-------+------------+----------------------+----------+--------------+----------+---------------+-----------+-----------+-----------+-------------+-----------------+--------------
+------------------
17327 | public | partsupp | 0 | 0 | 0 | 0 | 0 | 0 | 0 | | |
|
17294 | public | customer | 0 | 0 | 0 | 0 | 0 | 0 | 0 | | |
|
17158 | public | part | 0 | 0 | | | 0 | 0 | 0 | | |
|
17259 | public | supplier | 0 | 0 | 0 | 0 | 0 | 0 | 0 | | |
|
16633 | gp_toolkit | gp_disk_free | 0 | 0 | | | 0 | 0 | 0 | | |
|
17394 | public | lineitem | 0 | 0 | 0 | 0 | 0 | 0 | 0 | | |
|
17361 | public | orders | 0 | 0 | 0 | 0 | 0 | 0 | 0 | | |
|
16439 | gp_toolkit | __gp_masterid | 0 | 0 | | | 0 | 0 | 0 | | |
|
49164 | public | number_xdrive | 0 | 0 | | | 0 | 0 | 0 | | |
|
17193 | public | region | 0 | 0 | | | 0 | 0 | 0 | | |
|
49215 | public | number_gpfdist | 0 | 0 | | | 0 | 0 | 0 | | |
|
16494 | gp_toolkit | __gp_log_master_ext | 0 | 0 | | | 0 | 0 | 0 | | |
|
40972 | public | number | 0 | 0 | | | 0 | 0 | 0 | | |
|
16413 | gp_toolkit | __gp_localid | 0 | 0 | | | 0 | 0 | 0 | | |
|
16468 | gp_toolkit | __gp_log_segment_ext | 0 | 0 | | | 0 | 0 | 0 | | |
|
17226 | public | nation | 0 | 0 | 0 | 0 | 0 | 0 | 0 | | |
|
(16 rows)
tpch=# select * from pg_stat_user_indexes;
relid | indexrelid | schemaname | relname | indexrelname | idx_scan | idx_tup_read | idx_tup_fetch
-------+------------+------------+----------+-------------------------+----------+--------------+---------------
17259 | 17602 | public | supplier | idx_supplier_nation_key | 0 | 0 | 0
17327 | 17623 | public | partsupp | idx_partsupp_partkey | 0 | 0 | 0
17327 | 17644 | public | partsupp | idx_partsupp_suppkey | 0 | 0 | 0
17294 | 17663 | public | customer | idx_customer_nationkey | 0 | 0 | 0
17361 | 17684 | public | orders | idx_orders_custkey | 0 | 0 | 0
17394 | 17705 | public | lineitem | idx_lineitem_orderkey | 0 | 0 | 0
17394 | 17726 | public | lineitem | idx_lineitem_part_supp | 0 | 0 | 0
17226 | 17745 | public | nation | idx_nation_regionkey | 0 | 0 | 0
17394 | 17766 | public | lineitem | idx_lineitem_shipdate | 0 | 0 | 0
17361 | 17785 | public | orders | idx_orders_orderdate | 0 | 0 | 0
(10 rows)
3.查看表分區
select b.nspname||'.'||a.relname as tablename, d.parname as partname from pg_class a, pg_namespace b, pg_partition c,pg_partition_rule d where a.relnamespace = b.oid and b.nspname = 'public' and a.relname = 'customer' and a.oid = c.parrelid and c.oid = d.paroid order by parname;
tablename | partname
-----------+----------
(0 rows)
4.查看Distributed key
tpch=# select b.attname from pg_class a, pg_attribute b, pg_type c, gp_distribution_policy d, pg_namespace e where d.localoid = a.oid and a.relnamespace = e.oid and e.nspname = 'public' and a.relname= 'customer' and a.oid = b.attrelid and b.atttypid = c.oid and b.attnum > 0 and b.attnum = any(d.attrnums) order by attnum;
attname
-----------
c_custkey
(1 row)
5.查看當前存活的查詢
select procpid as pid, sess_id as session, usename as user, current_query as query, waiting,date_trunc('second',query_start) as start_time, client_addr as useraddr from pg_stat_activity where datname ='$PGDATABADE'
and current_query not like '%from pg_stat_activity%where datname =%' order by start_time;
示例:
tpch=# select procpid as pid, sess_id as session, usename as user, current_query as query, waiting,date_trunc('second',query_start) as start_time, client_addr as useraddr from pg_stat_activity where datname ='tpch'
tpch-# and current_query not like '%from pg_stat_activity%where datname =%' order by start_time;
pid | session | user | query | waiting | start_time | useraddr
-----+---------+------+-------+---------+------------+----------
(0 rows)
最後更新:2017-06-11 14:33:06
上一篇:
javaEE 後台框架 SpringMVC Mybatis Shiro druid Bootstrap HTML5
下一篇:
Greenplum/Deepgreen ERROR: insufficient memory reserved for statement (memquota.c:228)
Android源碼分析-點擊事件派發機製
《Spring實戰(第4版)》——2.3 通過Java代碼裝配bean
樹莓派使用 DHT11 溫濕度傳感器
開發者論壇一周精粹(第六期):阿裏B2B研發管理難題如何應對?打造強有力的技術中台
C++編程規範之12:懂得何時和如何進行並發性編程
如何徹底隱藏係統自帶的UITabBar
阿裏雲拓展歐洲戰場 欲再建數據中心
Vim 編輯器的兼容模式
較實用的android Gallery Demo 網絡讀取圖片,定時切換,正反無限循環,圖片滿屏,遮罩標題文字,切換圓點顯示,多線程控製
android訪問本地web(不是127.0.0.1而是10.0.2.2)