GP之状态查看
检查系统状态
一个Greenplum数据库系统由横跨多台机器的多个PostgreSQL实例(Master和Segment)构成。要监控一个 Greenplum数据库系统,需要了解整个系统的信息以及个体实例的状态信息。gpstate 工具提供有关一个Greenplum数据库系统的状态信息。
查看Master和Segment的状态及配置
默认的gpstate行为是检查Segment实例并且显示可用和失效Segment的一个简短状态。 例如,要快速查看Greenplum数据库系统的状态:
$ gpstate
[gpadmin@gp-mdw ~]$ gpstate
20221217:18:04:26:024257 gpstate:gp-mdw:gpadmin-[INFO]:-Starting gpstate with args:
20221217:18:04:26:024257 gpstate:gp-mdw:gpadmin-[INFO]:-local Greenplum Version: 'postgres (Greenplum Database) 6.22.0 build commit:4b6c079bc3aed35b2f161c377e208185f9310a69 Open Source'
20221217:18:04:26:024257 gpstate:gp-mdw:gpadmin-[INFO]:-master Greenplum Version: 'PostgreSQL 9.4.26 (Greenplum Database 6.22.0 build commit:4b6c079bc3aed35b2f161c377e208185f9310a69 Open Source) on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 6.4.0, 64-bit compiled on Sep 8 2022 22:41:44'
20221217:18:04:26:024257 gpstate:gp-mdw:gpadmin-[INFO]:-Obtaining Segment details from master...
20221217:18:04:26:024257 gpstate:gp-mdw:gpadmin-[INFO]:-Gathering data from segments...
20221217:18:04:26:024257 gpstate:gp-mdw:gpadmin-[INFO]:-Greenplum instance status summary
20221217:18:04:26:024257 gpstate:gp-mdw:gpadmin-[INFO]:-----------------------------------------------------
20221217:18:04:26:024257 gpstate:gp-mdw:gpadmin-[INFO]:- Master instance = Active
20221217:18:04:26:024257 gpstate:gp-mdw:gpadmin-[INFO]:- Master standby = gp-smdw
20221217:18:04:26:024257 gpstate:gp-mdw:gpadmin-[INFO]:- Standby master state = Standby host passive
20221217:18:04:26:024257 gpstate:gp-mdw:gpadmin-[INFO]:- Total segment instance count from metadata = 12
20221217:18:04:26:024257 gpstate:gp-mdw:gpadmin-[INFO]:-----------------------------------------------------
20221217:18:04:26:024257 gpstate:gp-mdw:gpadmin-[INFO]:- Primary Segment Status
20221217:18:04:26:024257 gpstate:gp-mdw:gpadmin-[INFO]:-----------------------------------------------------
20221217:18:04:26:024257 gpstate:gp-mdw:gpadmin-[INFO]:- Total primary segments = 6
20221217:18:04:26:024257 gpstate:gp-mdw:gpadmin-[INFO]:- Total primary segment valid (at master) = 6
20221217:18:04:26:024257 gpstate:gp-mdw:gpadmin-[INFO]:- Total primary segment failures (at master) = 0
20221217:18:04:26:024257 gpstate:gp-mdw:gpadmin-[INFO]:- Total number of postmaster.pid files missing = 0
20221217:18:04:26:024257 gpstate:gp-mdw:gpadmin-[INFO]:- Total number of postmaster.pid files found = 6
20221217:18:04:26:024257 gpstate:gp-mdw:gpadmin-[INFO]:- Total number of postmaster.pid PIDs missing = 0
20221217:18:04:26:024257 gpstate:gp-mdw:gpadmin-[INFO]:- Total number of postmaster.pid PIDs found = 6
20221217:18:04:26:024257 gpstate:gp-mdw:gpadmin-[INFO]:- Total number of /tmp lock files missing = 0
20221217:18:04:26:024257 gpstate:gp-mdw:gpadmin-[INFO]:- Total number of /tmp lock files found = 6
20221217:18:04:26:024257 gpstate:gp-mdw:gpadmin-[INFO]:- Total number postmaster processes missing = 0
20221217:18:04:26:024257 gpstate:gp-mdw:gpadmin-[INFO]:- Total number postmaster processes found = 6
20221217:18:04:26:024257 gpstate:gp-mdw:gpadmin-[INFO]:-----------------------------------------------------
20221217:18:04:26:024257 gpstate:gp-mdw:gpadmin-[INFO]:- Mirror Segment Status
20221217:18:04:26:024257 gpstate:gp-mdw:gpadmin-[INFO]:-----------------------------------------------------
20221217:18:04:26:024257 gpstate:gp-mdw:gpadmin-[INFO]:- Total mirror segments = 6
20221217:18:04:26:024257 gpstate:gp-mdw:gpadmin-[INFO]:- Total mirror segment valid (at master) = 6
20221217:18:04:26:024257 gpstate:gp-mdw:gpadmin-[INFO]:- Total mirror segment failures (at master) = 0
20221217:18:04:26:024257 gpstate:gp-mdw:gpadmin-[INFO]:- Total number of postmaster.pid files missing = 0
20221217:18:04:26:024257 gpstate:gp-mdw:gpadmin-[INFO]:- Total number of postmaster.pid files found = 6
20221217:18:04:26:024257 gpstate:gp-mdw:gpadmin-[INFO]:- Total number of postmaster.pid PIDs missing = 0
20221217:18:04:26:024257 gpstate:gp-mdw:gpadmin-[INFO]:- Total number of postmaster.pid PIDs found = 6
20221217:18:04:26:024257 gpstate:gp-mdw:gpadmin-[INFO]:- Total number of /tmp lock files missing = 0
20221217:18:04:26:024257 gpstate:gp-mdw:gpadmin-[INFO]:- Total number of /tmp lock files found = 6
20221217:18:04:26:024257 gpstate:gp-mdw:gpadmin-[INFO]:- Total number postmaster processes missing = 0
20221217:18:04:26:024257 gpstate:gp-mdw:gpadmin-[INFO]:- Total number postmaster processes found = 6
20221217:18:04:26:024257 gpstate:gp-mdw:gpadmin-[INFO]:- Total number mirror segments acting as primary segments = 0
20221217:18:04:26:024257 gpstate:gp-mdw:gpadmin-[INFO]:- Total number mirror segments acting as mirror segments = 6
20221217:18:04:26:024257 gpstate:gp-mdw:gpadmin-[INFO]:-----------------------------------------------------
要查看Greenplum数据库阵列配置更详细的信息,使用带有-s选项的gpstate:
$ gpstate -s
[gpadmin@gp-mdw ~]$ gpstate -s
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:-Starting gpstate with args: -s
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:-local Greenplum Version: 'postgres (Greenplum Database) 6.22.0 build commit:4b6c079bc3aed35b2f161c377e208185f9310a69 Open Source'
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:-master Greenplum Version: 'PostgreSQL 9.4.26 (Greenplum Database 6.22.0 build commit:4b6c079bc3aed35b2f161c377e208185f9310a69 Open Source) on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 6.4.0, 64-bit compiled on Sep 8 2022 22:41:44'
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:-Obtaining Segment details from master...
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:-Gathering data from segments...
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:-----------------------------------------------------
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:--Master Configuration & Status
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:-----------------------------------------------------
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Master host = gp-mdw
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Master postgres process ID = 1551
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Master data directory = /data/master/gpseg-1
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Master port = 5432
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Master current role = dispatch
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Greenplum initsystem version = 6.22.0 build commit:4b6c079bc3aed35b2f161c377e208185f9310a69 Open Source
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Greenplum current version = PostgreSQL 9.4.26 (Greenplum Database 6.22.0 build commit:4b6c079bc3aed35b2f161c377e208185f9310a69 Open Source) on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 6.4.0, 64-bit compiled on Sep 8 2022 22:41:44
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Postgres version = 9.4.26
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Master standby = gp-smdw
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Standby master state = Standby host passive
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:-----------------------------------------------------
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:-Segment Instance Status Report
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:-----------------------------------------------------
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Segment Info
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Hostname = gp-sdw1
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Address = gp-sdw1
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Datadir = /data/p1/gpseg0
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Port = 6000
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Mirroring Info
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Current role = Primary
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Preferred role = Primary
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Mirror status = Synchronized
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Replication Info
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Current write location = 0/12238198
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Bytes remaining to send to mirror = 0
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Status
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- PID = 1761
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Configuration reports status as = Up
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Database status = Up
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:-----------------------------------------------------
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Segment Info
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Hostname = gp-sdw2
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Address = gp-sdw2
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Datadir = /data/m1/gpseg0
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Port = 7000
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Mirroring Info
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Current role = Mirror
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Preferred role = Mirror
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Mirror status = Streaming
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Replication Info
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- WAL Sent Location = 0/12238198
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- WAL Flush Location = 0/12238198
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- WAL Replay Location = 0/12238198
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Bytes received but remain to flush = 0
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Bytes received but remain to replay = 0
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Status
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- PID = 1513
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Configuration reports status as = Up
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Segment status = Up
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:-----------------------------------------------------
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Segment Info
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Hostname = gp-sdw1
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Address = gp-sdw1
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Datadir = /data/p2/gpseg1
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Port = 6001
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Mirroring Info
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Current role = Primary
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Preferred role = Primary
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Mirror status = Synchronized
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Replication Info
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Current write location = 0/121C1568
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Bytes remaining to send to mirror = 0
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Status
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- PID = 1774
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Configuration reports status as = Up
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Database status = Up
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:-----------------------------------------------------
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Segment Info
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Hostname = gp-smdw
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Address = gp-smdw
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Datadir = /data/m2/gpseg1
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Port = 7001
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Mirroring Info
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Current role = Mirror
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Preferred role = Mirror
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Mirror status = Streaming
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Replication Info
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- WAL Sent Location = 0/121C1568
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- WAL Flush Location = 0/121C1568
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- WAL Replay Location = 0/121C1568
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Bytes received but remain to flush = 0
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Bytes received but remain to replay = 0
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Status
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- PID = 1509
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Configuration reports status as = Up
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Segment status = Up
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:-----------------------------------------------------
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Segment Info
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Hostname = gp-sdw2
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Address = gp-sdw2
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Datadir = /data/p1/gpseg2
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Port = 6000
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Mirroring Info
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Current role = Primary
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Preferred role = Primary
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Mirror status = Synchronized
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Replication Info
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Current write location = 0/12275B10
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Bytes remaining to send to mirror = 0
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Status
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- PID = 1522
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Configuration reports status as = Up
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Database status = Up
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:-----------------------------------------------------
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Segment Info
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Hostname = gp-smdw
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Address = gp-smdw
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Datadir = /data/m1/gpseg2
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Port = 7000
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Mirroring Info
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Current role = Mirror
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Preferred role = Mirror
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Mirror status = Streaming
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Replication Info
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- WAL Sent Location = 0/12275B10
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- WAL Flush Location = 0/12275B10
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- WAL Replay Location = 0/12275B10
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Bytes received but remain to flush = 0
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Bytes received but remain to replay = 0
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Status
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- PID = 1514
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Configuration reports status as = Up
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Segment status = Up
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:-----------------------------------------------------
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Segment Info
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Hostname = gp-sdw2
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Address = gp-sdw2
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Datadir = /data/p2/gpseg3
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Port = 6001
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Mirroring Info
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Current role = Primary
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Preferred role = Primary
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Mirror status = Synchronized
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Replication Info
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Current write location = 0/122C1498
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Bytes remaining to send to mirror = 0
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Status
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- PID = 1517
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Configuration reports status as = Up
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Database status = Up
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:-----------------------------------------------------
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Segment Info
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Hostname = gp-sdw1
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Address = gp-sdw1
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Datadir = /data/m2/gpseg3
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Port = 7001
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Mirroring Info
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Current role = Mirror
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Preferred role = Mirror
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Mirror status = Streaming
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Replication Info
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- WAL Sent Location = 0/122C1498
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- WAL Flush Location = 0/122C1498
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- WAL Replay Location = 0/122C1498
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Bytes received but remain to flush = 0
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Bytes received but remain to replay = 0
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Status
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- PID = 1765
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Configuration reports status as = Up
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Segment status = Up
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:-----------------------------------------------------
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Segment Info
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Hostname = gp-smdw
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Address = gp-smdw
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Datadir = /data/p1/gpseg4
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Port = 6000
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Mirroring Info
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Current role = Primary
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Preferred role = Primary
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Mirror status = Synchronized
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Replication Info
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Current write location = 0/122BC6D0
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Bytes remaining to send to mirror = 0
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Status
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- PID = 1519
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Configuration reports status as = Up
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Database status = Up
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:-----------------------------------------------------
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Segment Info
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Hostname = gp-sdw1
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Address = gp-sdw1
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Datadir = /data/m1/gpseg4
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Port = 7000
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Mirroring Info
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Current role = Mirror
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Preferred role = Mirror
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Mirror status = Streaming
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Replication Info
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- WAL Sent Location = 0/122BC6D0
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- WAL Flush Location = 0/122BC6D0
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- WAL Replay Location = 0/122BC6D0
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Bytes received but remain to flush = 0
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Bytes received but remain to replay = 0
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Status
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- PID = 1770
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Configuration reports status as = Up
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Segment status = Up
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:-----------------------------------------------------
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Segment Info
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Hostname = gp-smdw
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Address = gp-smdw
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Datadir = /data/p2/gpseg5
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Port = 6001
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Mirroring Info
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Current role = Primary
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Preferred role = Primary
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Mirror status = Synchronized
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Replication Info
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Current write location = 0/12238EA0
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Bytes remaining to send to mirror = 0
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Status
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- PID = 1523
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Configuration reports status as = Up
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Database status = Up
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:-----------------------------------------------------
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Segment Info
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Hostname = gp-sdw2
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Address = gp-sdw2
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Datadir = /data/m2/gpseg5
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Port = 7001
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Mirroring Info
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Current role = Mirror
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Preferred role = Mirror
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Mirror status = Streaming
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Replication Info
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- WAL Sent Location = 0/12238EA0
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- WAL Flush Location = 0/12238EA0
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- WAL Replay Location = 0/12238EA0
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Bytes received but remain to flush = 0
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Bytes received but remain to replay = 0
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Status
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- PID = 1526
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Configuration reports status as = Up
20221217:18:05:00:024324 gpstate:gp-mdw:gpadmin-[INFO]:- Segment status = Up
查看镜像配置和状态
如果在使用镜像作为数据冗余,用户可能想要看看系统中的镜像Segment实例列表、它们当前的同步状态以及 镜像和主Segment之间的映射。例如,要查看一个系统中的镜像Segment和它们的状态:5
$ gpstate -m
[gpadmin@gp-mdw ~]$ gpstate -m
20221217:18:05:47:024395 gpstate:gp-mdw:gpadmin-[INFO]:-Starting gpstate with args: -m
20221217:18:05:47:024395 gpstate:gp-mdw:gpadmin-[INFO]:-local Greenplum Version: 'postgres (Greenplum Database) 6.22.0 build commit:4b6c079bc3aed35b2f161c377e208185f9310a69 Open Source'
20221217:18:05:47:024395 gpstate:gp-mdw:gpadmin-[INFO]:-master Greenplum Version: 'PostgreSQL 9.4.26 (Greenplum Database 6.22.0 build commit:4b6c079bc3aed35b2f161c377e208185f9310a69 Open Source) on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 6.4.0, 64-bit compiled on Sep 8 2022 22:41:44'
20221217:18:05:47:024395 gpstate:gp-mdw:gpadmin-[INFO]:-Obtaining Segment details from master...
20221217:18:05:47:024395 gpstate:gp-mdw:gpadmin-[INFO]:--------------------------------------------------------------
20221217:18:05:47:024395 gpstate:gp-mdw:gpadmin-[INFO]:--Current GPDB mirror list and status
20221217:18:05:47:024395 gpstate:gp-mdw:gpadmin-[INFO]:--Type = Spread
20221217:18:05:47:024395 gpstate:gp-mdw:gpadmin-[INFO]:--------------------------------------------------------------
20221217:18:05:47:024395 gpstate:gp-mdw:gpadmin-[INFO]:- Mirror Datadir Port Status Data Status
20221217:18:05:47:024395 gpstate:gp-mdw:gpadmin-[INFO]:- gp-sdw2 /data/m1/gpseg0 7000 Passive Synchronized
20221217:18:05:47:024395 gpstate:gp-mdw:gpadmin-[INFO]:- gp-smdw /data/m2/gpseg1 7001 Passive Synchronized
20221217:18:05:47:024395 gpstate:gp-mdw:gpadmin-[INFO]:- gp-smdw /data/m1/gpseg2 7000 Passive Synchronized
20221217:18:05:47:024395 gpstate:gp-mdw:gpadmin-[INFO]:- gp-sdw1 /data/m2/gpseg3 7001 Passive Synchronized
20221217:18:05:47:024395 gpstate:gp-mdw:gpadmin-[INFO]:- gp-sdw1 /data/m1/gpseg4 7000 Passive Synchronized
20221217:18:05:47:024395 gpstate:gp-mdw:gpadmin-[INFO]:- gp-sdw2 /data/m2/gpseg5 7001 Passive Synchronized
要查看主Segment到镜像Segment的映射:
$ gpstate -c
[gpadmin@gp-mdw ~]$ gpstate -c
20221217:18:06:12:024420 gpstate:gp-mdw:gpadmin-[INFO]:-Starting gpstate with args: -c
20221217:18:06:12:024420 gpstate:gp-mdw:gpadmin-[INFO]:-local Greenplum Version: 'postgres (Greenplum Database) 6.22.0 build commit:4b6c079bc3aed35b2f161c377e208185f9310a69 Open Source'
20221217:18:06:12:024420 gpstate:gp-mdw:gpadmin-[INFO]:-master Greenplum Version: 'PostgreSQL 9.4.26 (Greenplum Database 6.22.0 build commit:4b6c079bc3aed35b2f161c377e208185f9310a69 Open Source) on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 6.4.0, 64-bit compiled on Sep 8 2022 22:41:44'
20221217:18:06:12:024420 gpstate:gp-mdw:gpadmin-[INFO]:-Obtaining Segment details from master...
20221217:18:06:12:024420 gpstate:gp-mdw:gpadmin-[INFO]:--------------------------------------------------------------
20221217:18:06:12:024420 gpstate:gp-mdw:gpadmin-[INFO]:--Current GPDB mirror list and status
20221217:18:06:12:024420 gpstate:gp-mdw:gpadmin-[INFO]:--Type = Spread
20221217:18:06:12:024420 gpstate:gp-mdw:gpadmin-[INFO]:--------------------------------------------------------------
20221217:18:06:12:024420 gpstate:gp-mdw:gpadmin-[INFO]:- Status Data State Primary Datadir Port Mirror Datadir Port
20221217:18:06:12:024420 gpstate:gp-mdw:gpadmin-[INFO]:- Primary Active, Mirror Available Synchronized gp-sdw1 /data/p1/gpseg0 6000 gp-sdw2 /data/m1/gpseg0 7000
20221217:18:06:12:024420 gpstate:gp-mdw:gpadmin-[INFO]:- Primary Active, Mirror Available Synchronized gp-sdw1 /data/p2/gpseg1 6001 gp-smdw /data/m2/gpseg1 7001
20221217:18:06:12:024420 gpstate:gp-mdw:gpadmin-[INFO]:- Primary Active, Mirror Available Synchronized gp-sdw2 /data/p1/gpseg2 6000 gp-smdw /data/m1/gpseg2 7000
20221217:18:06:12:024420 gpstate:gp-mdw:gpadmin-[INFO]:- Primary Active, Mirror Available Synchronized gp-sdw2 /data/p2/gpseg3 6001 gp-sdw1 /data/m2/gpseg3 7001
20221217:18:06:12:024420 gpstate:gp-mdw:gpadmin-[INFO]:- Primary Active, Mirror Available Synchronized gp-smdw /data/p1/gpseg4 6000 gp-sdw1 /data/m1/gpseg4 7000
20221217:18:06:12:024420 gpstate:gp-mdw:gpadmin-[INFO]:- Primary Active, Mirror Available Synchronized gp-smdw /data/p2/gpseg5 6001 gp-sdw2 /data/m2/gpseg5 7001
20221217:18:06:12:024420 gpstate:gp-mdw:gpadmin-[INFO]:--------------------------------------------------------------
要查看后备Master镜像的状态:
$ gpstate -f
[gpadmin@gp-mdw ~]$ gpstate -f
20221217:18:06:38:024445 gpstate:gp-mdw:gpadmin-[INFO]:-Starting gpstate with args: -f
20221217:18:06:38:024445 gpstate:gp-mdw:gpadmin-[INFO]:-local Greenplum Version: 'postgres (Greenplum Database) 6.22.0 build commit:4b6c079bc3aed35b2f161c377e208185f9310a69 Open Source'
20221217:18:06:38:024445 gpstate:gp-mdw:gpadmin-[INFO]:-master Greenplum Version: 'PostgreSQL 9.4.26 (Greenplum Database 6.22.0 build commit:4b6c079bc3aed35b2f161c377e208185f9310a69 Open Source) on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 6.4.0, 64-bit compiled on Sep 8 2022 22:41:44'
20221217:18:06:38:024445 gpstate:gp-mdw:gpadmin-[INFO]:-Obtaining Segment details from master...
20221217:18:06:38:024445 gpstate:gp-mdw:gpadmin-[INFO]:-Standby master details
20221217:18:06:38:024445 gpstate:gp-mdw:gpadmin-[INFO]:-----------------------
20221217:18:06:38:024445 gpstate:gp-mdw:gpadmin-[INFO]:- Standby address = gp-smdw
20221217:18:06:38:024445 gpstate:gp-mdw:gpadmin-[INFO]:- Standby data directory = /data/master/gpseg-1
20221217:18:06:38:024445 gpstate:gp-mdw:gpadmin-[INFO]:- Standby port = 5432
20221217:18:06:38:024445 gpstate:gp-mdw:gpadmin-[INFO]:- Standby PID = 1633
20221217:18:06:38:024445 gpstate:gp-mdw:gpadmin-[INFO]:- Standby status = Standby host passive
20221217:18:06:38:024445 gpstate:gp-mdw:gpadmin-[INFO]:--------------------------------------------------------------
20221217:18:06:38:024445 gpstate:gp-mdw:gpadmin-[INFO]:--pg_stat_replication
20221217:18:06:38:024445 gpstate:gp-mdw:gpadmin-[INFO]:--------------------------------------------------------------
20221217:18:06:38:024445 gpstate:gp-mdw:gpadmin-[INFO]:--WAL Sender State: streaming
20221217:18:06:38:024445 gpstate:gp-mdw:gpadmin-[INFO]:--Sync state: sync
20221217:18:06:38:024445 gpstate:gp-mdw:gpadmin-[INFO]:--Sent Location: 0/D683498
20221217:18:06:38:024445 gpstate:gp-mdw:gpadmin-[INFO]:--Flush Location: 0/D683498
20221217:18:06:38:024445 gpstate:gp-mdw:gpadmin-[INFO]:--Replay Location: 0/D683498
20221217:18:06:38:024445 gpstate:gp-mdw:gpadmin-[INFO]:--------------------------------------------------------------
检查磁盘空间使用
一个数据库管理员最重要的监控任务是确保Master和Segment数据目录所在的文件系统的使用率不会超过 70%的。完全占满的数据磁盘不会导致数据损坏,但是可能会妨碍数据库的正常操作。如果磁盘占用得太满, 可能会导致数据库服务器关闭。
可以使用gp_toolkit管理模式中的gp_disk_free外部表 来检查Segment主机文件系统中的剩余空闲空间(以KB为计量单位)。例如:
=# SELECT * FROM gp_toolkit.gp_disk_free ORDER BY dfsegment;
检查分布式数据库和表的大小
gp_toolkit管理模式包含几个可以用来判断Greenplum数据库的分布式数据库、 模式、表或索引磁盘空间使用的视图。
用于检查数据库对象尺寸和磁盘空间的视图列表,请见Greenplum Database Reference Guide.
查看一个数据库的磁盘空间使用情况
要查看一个数据库的总大小(以字节计),使用gp_toolkit管理模式中的gp_size_of_database 视图。例如:
=> SELECT * FROM gp_toolkit.gp_size_of_database ORDER BY sodddatname;
查看一个表的磁盘空间使用情况
gp_toolkit管理模式包含几个检查表大小的视图。表大小视图根据对象ID (而不是名称)列出表。要根据一个表的名称检查其尺寸,必须在pg_class表中查找关系名称 (relname)。例如:
=> SELECT relname AS name, sotdsize AS size, sotdtoastsize AS toast, sotdadditionalsize AS other FROM gp_toolkit.gp_size_of_table_disk as sotd, pg_class WHERE sotd.sotdoid=pg_class.oid ORDER BY relname;
可用的表大小视图的列表请见Greenplum Database Reference Guide.
查看索引的磁盘空间使用情况
gp_toolkit管理模式包含几个用于检查索引大小的视图。要查看一个表上所有索引的总大小,使用 gp_size_of_all_table_indexes视图。要查看一个特定索引的大小,使用gp_size_of_index视图。 该索引大小视图根据对象ID(而不是名称)列出表和索引。要根据一个索引的名称查看其尺寸,必须在pg_class 表中查找关系名称(relname)。例如:
=> SELECT soisize, relname as indexname FROM pg_class, gp_toolkit.gp_size_of_index WHERE pg_class.oid=gp_size_of_index.soioid AND pg_class.relkind='i';
检查数据分布倾斜
Greenplum数据库中所有的表都是分布式的,意味着它们的数据被按规则划分到系统中的所有Segment上。 不均匀分布的数据可能会削弱查询处理性能。一个表的分布策略在表创建时被确定。有关选择表分布策略的信息, 请见下列主题:
gp_toolkit管理模式还包含一些用于检查表上数据分布倾斜的视图。有关如何检查非均匀数据分布的信息, 请见Greenplum Database Reference Guide.
查看一个表的分布键
要查看一个表中被用作数据分布键的列,可以使用psql中的\d+ 元命令来检查表的定义。例如:
=#\d+ sales Table "retail.sales" Column | Type | Modifiers | Description -------------+--------------+-----------+------------- sale_id | integer | | amt | float | | date | date | | Has OIDs: no Distributed by: (sale_id)
当我们创建复制表时,Greenplum数据库会在每个Segment上都存储一份完整的表数据。复制表没有分布键。 \d+元命令会展示分布表的分布键,复制表展示状态为Distributed Replicated。
查看数据分布
要查看一个表中行的数据分布(每个Segment上的行数),可以运行一个这样的查询:
=# SELECT gp_segment_id, count(*) FROM table_name GROUP BY gp_segment_id;
如果所有的Segment都有大致相同的行数,一个表就可以被认为是分布均匀的。
如果在复制表上运行该查询会执行失败,因为Greenplum数据库不允许用户查询复制表的gp_segment_id 系统列数据。由于每个Segment上都有一份完整的表数据,复制表必然是均匀的。
检查查询过程倾斜
当一个查询被执行时,所有的Segment应该具有等量的负载来保证最好的性能。如果发现了一个执行性能低下的查询, 可能需要使用EXPLAIN命令进行深入研究。有关使用EXPLAIN命令和查询 分析的信息,请见查询分析.
如果表的数据分布策略与查询谓词没有很好地匹配,查询执行负载可能会倾斜。要检查执行倾斜,可以运行一个这样 的查询:
=# SELECT gp_segment_id, count(*) FROM table_name WHERE column='value' GROUP BY gp_segment_id;
这将显示对于给定的WHERE谓词,Segment会返回的行数。
如查看数据分布所说的, 该查询在复制表上运行时也会报错,因为在复制表上查询的 gp_segment_id列不具有参考价值。
避免极度倾斜警告
当执行一个使用哈希连接操作的查询时,可能会收到下面的警告消息:
Extreme skew in the innerside of Hashjoin
- 确保所有的事实表都被分析过。
- 验证该查询用到的任何已填充临时表都被分析过。
- 查看该查询的EXPLAIN ANALYZE计划,并且在其中查找以下信息:
- 如果有带多列过滤的扫描产生超过预估的行数,则将gp_selectivity_damping_factor 服务器配置参数的值设置为当前值的2倍以上并且重新测试该查询。
- 如果在连接一个相对较小(小于5000行)的单一事实表时发生倾斜,将gp_segments_for_planner 服务器配置参数设置为1并且重新测试该查询。
- 检查应用于该查询的过滤属性是否匹配基表的分布键。如果过滤属性和分布键相同,考虑用不同的 分布键重新分布一些基表。
- 检查连接键的基数。如果基数较低,尝试用不同的连接列或者表上额外的过滤属性来重写该查询以降低行数。 这些更改可能会改变查询的语义。
查看数据库对象的元数据信息
Greenplum数据库在其系统目录中跟踪各种有关存储在数据库中对象(例如表、视图、索引等等)和 全局对象(例如角色和表空间)的元数据信息。
查看最后一个执行的操作
可以使用系统视图pg_stat_operations和 pg_stat_partition_operations 查看在一个对象(例如一个表)上执行的动作。例如,要查看在一个表上执行的动作,比如它何时被创建以及它上一次是什么时候被清理和分析:
=> SELECT schemaname as schema, objname as table, usename as role, actionname as action, subtype as type, statime as time FROM pg_stat_operations WHERE objname='cust'; schema | table | role | action | type | time