PostgreSQL citus, Greenplum 分布式执行计划 DEBUG

本文涉及的产品
云数据库 RDS SQL Server,基础系列 2核4GB
RDS PostgreSQL Serverless,0.5-4RCU 50GB 3个月
推荐场景:
对影评进行热评分析
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
简介: 标签PostgreSQL , citus , sharding , Greenplum , explain , debug背景开启DEBUG,可以观察citus, Greenplum的SQL分布式执行计划,下发情况,主节点,数据节点交互情况。

标签

PostgreSQL , citus , sharding , Greenplum , explain , debug


背景

开启DEBUG,可以观察citus, Greenplum的SQL分布式执行计划,下发情况,主节点,数据节点交互情况。

执行explain前,打开DEBUG。

set client_min_messages ='debug5';    
\set VERBOSITY verbose    
explain
explain (analyze,verbose,timing,costs,buffers)

例子

Greenplum

1、 所有节点执行,聚合

postgres=# explain select count(*) from t;    
DEBUG5:  First char: 'Q'; gp_role = 'dispatch'.    
DEBUG1:  Message type Q received by from libpq, len = 32    
DEBUG5:  Simple query stmt: explain select count(*) from t;.    
DEBUG5:  setupRegularDtxContext leaving with DistributedTransactionContext = 'Master Distributed-Capable'.    
DEBUG3:  StartTransactionCommand    
DEBUG5:  createDtx created new distributed transaction gid = 1535334693-0000001383, gxid = 1383.    
DEBUG5:  setting SharedLocalSnapshotSlot->startTimestamp = 588738486258830[old=588738484208328])    
DEBUG5:  [Distributed Snapshot #0] *StartTransaction* (gxid = 1383, xid = 0, 'Master Distributed-Capable')    
DEBUG3:  StartTransaction    
DEBUG3:  name: unnamed; blockState:       DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:    
DEBUG5:  StartTransaction in DTX Context = 'Master Distributed-Capable', distributed transaction {timestamp 0, xid 0} for local xid 0    
LOG:  statement: explain select count(*) from t;    
DEBUG5:  setupRegularDtxContext leaving with DistributedTransactionContext = 'Master Distributed-Capable'.    
DEBUG5:  GetSnapshotData maxCount 1000, inProgressEntryArray 0x3c45be0    
DEBUG5:  GetSnapshotData serializable true, xmin 0    
DEBUG5:  GetSnapshotData setting globalxmin and xmin to 7159    
DEBUG5:  FillInDistributedSnapshot DTX Context = 'Master Distributed-Capable'    
DEBUG5:  createDtxSnapshot distributed snapshot has xmin = 1383, count = 0, xmax = 1383.    
DEBUG5:  [Distributed Snapshot #1284] *Create* (gxid = 1383, 'Master Distributed-Capable')    
DEBUG5:  Got distributed snapshot from DistributedSnapshotWithLocalXids_Create = true    
DEBUG5:  GetSnapshotData(): WRITER currentcommandid 0 curcid 0 segmatesync 0    
DEBUG3:  ProcessUtility    
DEBUG5:  [Distributed Snapshot #0] (gxid = 1383, 'Master Distributed-Capable')    
DEBUG5:  GetSnapshotData maxCount 1000, inProgressEntryArray 0x3c4ef00    
DEBUG5:  GetSnapshotData serializable false, xmin 7159    
DEBUG5:  GetSnapshotData setting globalxmin and xmin to 7159    
DEBUG5:  FillInDistributedSnapshot DTX Context = 'Master Distributed-Capable'    
DEBUG5:  createDtxSnapshot distributed snapshot has xmin = 1383, count = 0, xmax = 1383.    
DEBUG5:  [Distributed Snapshot #1285] *Create* (gxid = 1383, 'Master Distributed-Capable')    
DEBUG5:  Got distributed snapshot from DistributedSnapshotWithLocalXids_Create = true    
DEBUG5:  GetSnapshotData(): WRITER currentcommandid 0 curcid 0 segmatesync 0    
DEBUG2:  cdb_estimate_rel_size  estimated 1 tuples and 1 pages    
DEBUG2:  cdb_estimate_rel_size  estimated 1 tuples and 3 pages    
DEBUG1:  Inserted entry for query (sessionid=44, commandcnt=43)    
DEBUG1:  Deleted entry for query (sessionid=44, commandcnt=43)    
DEBUG3:  CommitTransactionCommand    
DEBUG3:  CommitTransaction    
DEBUG3:  name: unnamed; blockState:       STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:    
DEBUG5:  prepareDtxTransaction ignoring not distributed gid = 1535334693-0000001383    
DEBUG5:  releaseGxact called for gid = 1535334693-0000001383 (index = 22)    
DEBUG5:  notifyCommittedDtxTransaction nothing to do (currentGxact == NULL)    
DEBUG5:  finishDistributedTransactionContext called to change DistributedTransactionContext from Master Distributed-Capable to Local Only (caller = CommitTransaction, gxid = 0)    
                                    QUERY PLAN                                        
----------------------------------------------------------------------------------    
 Aggregate  (cost=1.07..1.08 rows=1 width=8)    
   ->  Gather Motion 2:1  (slice1; segments: 2)  (cost=1.01..1.05 rows=1 width=8)    
         ->  Aggregate  (cost=1.01..1.02 rows=1 width=8)    
               ->  Seq Scan on t  (cost=0.00..1.01 rows=1 width=0)    
 Optimizer status: legacy query optimizer    
(5 rows)    

2、 非分布键,聚合

postgres=# explain select count(*) from t group by c1;    
DEBUG5:  First char: 'Q'; gp_role = 'dispatch'.    
DEBUG1:  Message type Q received by from libpq, len = 44    
DEBUG5:  Simple query stmt: explain select count(*) from t group by c1;.    
DEBUG5:  setupRegularDtxContext leaving with DistributedTransactionContext = 'Master Distributed-Capable'.    
DEBUG3:  StartTransactionCommand    
DEBUG5:  createDtx created new distributed transaction gid = 1535334693-0000001384, gxid = 1384.    
DEBUG5:  setting SharedLocalSnapshotSlot->startTimestamp = 588739780933404[old=588738486258830])    
DEBUG5:  [Distributed Snapshot #0] *StartTransaction* (gxid = 1384, xid = 0, 'Master Distributed-Capable')    
DEBUG3:  StartTransaction    
DEBUG3:  name: unnamed; blockState:       DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:    
DEBUG5:  StartTransaction in DTX Context = 'Master Distributed-Capable', distributed transaction {timestamp 0, xid 0} for local xid 0    
LOG:  statement: explain select count(*) from t group by c1;    
DEBUG5:  setupRegularDtxContext leaving with DistributedTransactionContext = 'Master Distributed-Capable'.    
DEBUG5:  GetSnapshotData maxCount 1000, inProgressEntryArray 0x3c45be0    
DEBUG5:  GetSnapshotData serializable true, xmin 0    
DEBUG5:  GetSnapshotData setting globalxmin and xmin to 7159    
DEBUG5:  FillInDistributedSnapshot DTX Context = 'Master Distributed-Capable'    
DEBUG5:  createDtxSnapshot distributed snapshot has xmin = 1384, count = 0, xmax = 1384.    
DEBUG5:  [Distributed Snapshot #1286] *Create* (gxid = 1384, 'Master Distributed-Capable')    
DEBUG5:  Got distributed snapshot from DistributedSnapshotWithLocalXids_Create = true    
DEBUG5:  GetSnapshotData(): WRITER currentcommandid 0 curcid 0 segmatesync 0    
DEBUG3:  ProcessUtility    
DEBUG5:  [Distributed Snapshot #0] (gxid = 1384, 'Master Distributed-Capable')    
DEBUG5:  GetSnapshotData maxCount 1000, inProgressEntryArray 0x3c4ef00    
DEBUG5:  GetSnapshotData serializable false, xmin 7159    
DEBUG5:  GetSnapshotData setting globalxmin and xmin to 7159    
DEBUG5:  FillInDistributedSnapshot DTX Context = 'Master Distributed-Capable'    
DEBUG5:  createDtxSnapshot distributed snapshot has xmin = 1384, count = 0, xmax = 1384.    
DEBUG5:  [Distributed Snapshot #1287] *Create* (gxid = 1384, 'Master Distributed-Capable')    
DEBUG5:  Got distributed snapshot from DistributedSnapshotWithLocalXids_Create = true    
DEBUG5:  GetSnapshotData(): WRITER currentcommandid 0 curcid 0 segmatesync 0    
DEBUG2:  cdb_estimate_rel_size  estimated 1 tuples and 1 pages    
DEBUG2:  cdb_estimate_rel_size  estimated 1 tuples and 3 pages    
DEBUG2:  HashAgg: ngroups = 1, memquota = 6.71089e+07, entrysize = 95.2    
DEBUG2:  HashAgg: nbuckets = 32, nentries = 5, nbatches = 0    
DEBUG2:  HashAgg: expected memory footprint = 972    
DEBUG2:  HashAgg: ngroups = 1, memquota = 6.71089e+07, entrysize = 95.2    
DEBUG2:  HashAgg: nbuckets = 32, nentries = 5, nbatches = 0    
DEBUG2:  HashAgg: expected memory footprint = 972    
DEBUG2:  HashAgg: ngroups = 1, memquota = 6.71089e+07, entrysize = 91.2    
DEBUG2:  HashAgg: nbuckets = 32, nentries = 5, nbatches = 0    
DEBUG2:  HashAgg: expected memory footprint = 952    
DEBUG2:  HashAgg: ngroups = 1, memquota = 6.71089e+07, entrysize = 91.2    
DEBUG2:  HashAgg: nbuckets = 32, nentries = 5, nbatches = 0    
DEBUG2:  HashAgg: expected memory footprint = 952    
DEBUG2:  HashAgg: ngroups = 1, memquota = 6.71089e+07, entrysize = 103.2    
DEBUG2:  HashAgg: nbuckets = 32, nentries = 5, nbatches = 0    
DEBUG2:  HashAgg: expected memory footprint = 1012    
DEBUG2:  HashAgg: ngroups = 1, memquota = 6.71089e+07, entrysize = 103.2    
DEBUG2:  HashAgg: nbuckets = 32, nentries = 5, nbatches = 0    
DEBUG2:  HashAgg: expected memory footprint = 1012    
DEBUG1:  Inserted entry for query (sessionid=44, commandcnt=45)    
DEBUG1:  Deleted entry for query (sessionid=44, commandcnt=45)    
DEBUG3:  CommitTransactionCommand    
DEBUG3:  CommitTransaction    
DEBUG3:  name: unnamed; blockState:       STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:    
DEBUG5:  prepareDtxTransaction ignoring not distributed gid = 1535334693-0000001384    
DEBUG5:  releaseGxact called for gid = 1535334693-0000001384 (index = 22)    
DEBUG5:  notifyCommittedDtxTransaction nothing to do (currentGxact == NULL)    
DEBUG5:  finishDistributedTransactionContext called to change DistributedTransactionContext from Master Distributed-Capable to Local Only (caller = CommitTransaction, gxid = 0)    
                                          QUERY PLAN                                               
-----------------------------------------------------------------------------------------------    
 Gather Motion 2:1  (slice2; segments: 2)  (cost=1.05..1.06 rows=1 width=12)    
   ->  HashAggregate  (cost=1.05..1.06 rows=1 width=12)    
         Group By: t.c1    
         ->  Redistribute Motion 2:2  (slice1; segments: 2)  (cost=1.01..1.03 rows=1 width=12)    
               Hash Key: t.c1    
               ->  HashAggregate  (cost=1.01..1.01 rows=1 width=12)    
                     Group By: t.c1    
                     ->  Seq Scan on t  (cost=0.00..1.01 rows=1 width=4)    
 Optimizer status: legacy query optimizer    
(9 rows)    

3、 分布键,聚合

postgres=# explain analyze select count(*) from t where id=1;    
DEBUG5:  00000: First char: 'Q'; gp_role = 'dispatch'.    
LOCATION:  PostgresMain, postgres.c:4921    
DEBUG1:  00000: Message type Q received by from libpq, len = 51    
LOCATION:  PostgresMain, postgres.c:4929    
DEBUG5:  00000: Simple query stmt: explain analyze select count(*) from t where id=1;.    
LOCATION:  PostgresMain, postgres.c:4936    
DEBUG5:  00000: setupRegularDtxContext leaving with DistributedTransactionContext = 'Master Distributed-Capable'.    
LOCATION:  setupRegularDtxContext, cdbtm.c:3469    
DEBUG3:  00000: StartTransactionCommand    
LOCATION:  start_xact_command, postgres.c:3187    
DEBUG5:  00000: createDtx created new distributed transaction gid = 1535334693-0000001386, gxid = 1386.    
LOCATION:  createDtx, cdbtm.c:2596    
DEBUG5:  00000: setting SharedLocalSnapshotSlot->startTimestamp = 588741036365223[old=588741015495884])    
LOCATION:  StartTransaction, xact.c:2331    
DEBUG5:  00000: [Distributed Snapshot #0] *StartTransaction* (gxid = 1386, xid = 0, 'Master Distributed-Capable')    
LOCATION:  StartTransaction, xact.c:2446    
DEBUG3:  00000: StartTransaction    
LOCATION:  ShowTransactionState, xact.c:5656    
DEBUG3:  00000: name: unnamed; blockState:       DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:    
LOCATION:  ShowTransactionStateRec, xact.c:5694    
DEBUG5:  00000: StartTransaction in DTX Context = 'Master Distributed-Capable', distributed transaction {timestamp 0, xid 0} for local xid 0    
LOCATION:  StartTransaction, xact.c:2531    
LOG:  00000: statement: explain analyze select count(*) from t where id=1;    
LOCATION:  exec_simple_query, postgres.c:1577    
DEBUG5:  00000: setupRegularDtxContext leaving with DistributedTransactionContext = 'Master Distributed-Capable'.    
LOCATION:  setupRegularDtxContext, cdbtm.c:3469    
DEBUG5:  00000: GetSnapshotData maxCount 1000, inProgressEntryArray 0x3c45be0    
LOCATION:  GetSnapshotData, procarray.c:1108    
DEBUG5:  00000: GetSnapshotData serializable true, xmin 0    
LOCATION:  GetSnapshotData, procarray.c:1342    
DEBUG5:  00000: GetSnapshotData setting globalxmin and xmin to 7159    
LOCATION:  GetSnapshotData, procarray.c:1363    
DEBUG5:  00000: FillInDistributedSnapshot DTX Context = 'Master Distributed-Capable'    
LOCATION:  FillInDistributedSnapshot, procarray.c:926    
DEBUG5:  00000: createDtxSnapshot distributed snapshot has xmin = 1386, count = 0, xmax = 1386.    
LOCATION:  createDtxSnapshot, cdbtm.c:2516    
DEBUG5:  00000: [Distributed Snapshot #1288] *Create* (gxid = 1386, 'Master Distributed-Capable')    
LOCATION:  createDtxSnapshot, cdbtm.c:2521    
DEBUG5:  00000: Got distributed snapshot from DistributedSnapshotWithLocalXids_Create = true    
LOCATION:  FillInDistributedSnapshot, procarray.c:949    
DEBUG5:  00000: GetSnapshotData(): WRITER currentcommandid 0 curcid 0 segmatesync 0    
LOCATION:  GetSnapshotData, procarray.c:1532    
DEBUG3:  00000: ProcessUtility    
LOCATION:  PortalRunUtility, pquery.c:1361    
DEBUG5:  00000: [Distributed Snapshot #0] (gxid = 1386, 'Master Distributed-Capable')    
LOCATION:  GetTransactionSnapshot, tqual.c:1407    
DEBUG5:  00000: GetSnapshotData maxCount 1000, inProgressEntryArray 0x3c4ef00    
LOCATION:  GetSnapshotData, procarray.c:1108    
DEBUG5:  00000: GetSnapshotData serializable false, xmin 7159    
LOCATION:  GetSnapshotData, procarray.c:1342    
DEBUG5:  00000: GetSnapshotData setting globalxmin and xmin to 7159    
LOCATION:  GetSnapshotData, procarray.c:1363    
DEBUG5:  00000: FillInDistributedSnapshot DTX Context = 'Master Distributed-Capable'    
LOCATION:  FillInDistributedSnapshot, procarray.c:926    
DEBUG5:  00000: createDtxSnapshot distributed snapshot has xmin = 1386, count = 0, xmax = 1386.    
LOCATION:  createDtxSnapshot, cdbtm.c:2516    
DEBUG5:  00000: [Distributed Snapshot #1289] *Create* (gxid = 1386, 'Master Distributed-Capable')    
LOCATION:  createDtxSnapshot, cdbtm.c:2521    
DEBUG5:  00000: Got distributed snapshot from DistributedSnapshotWithLocalXids_Create = true    
LOCATION:  FillInDistributedSnapshot, procarray.c:949    
DEBUG5:  00000: GetSnapshotData(): WRITER currentcommandid 0 curcid 0 segmatesync 0    
LOCATION:  GetSnapshotData, procarray.c:1532    
DEBUG2:  00000: cdb_estimate_rel_size  estimated 1 tuples and 1 pages    
LOCATION:  cdb_estimate_rel_size, plancat.c:501    
DEBUG2:  00000: cdb_estimate_rel_size  estimated 1 tuples and 3 pages    
LOCATION:  cdb_estimate_rel_size, plancat.c:501    
DEBUG4:  00000: CDBHASH started for 2 segment databases    
LOCATION:  makeCdbHash, cdbhash.c:106    
DEBUG1:  00000: Inserted entry for query (sessionid=44, commandcnt=48)    
LOCATION:  WorkfileQueryspace_InitEntry, workfile_queryspace.c:299    
DEBUG5:  00000: dtmPreCommand going distributed (all gangs) for gid = 1535334693-0000001386 (ExecutorStart, detail = '(none)')    
LOCATION:  dtmPreCommand, cdbtm.c:465    
DEBUG1:  00000: Query plan size to dispatch: 1KB    
LOCATION:  cdbdisp_buildPlanQueryParms, cdbdisp_query.c:605    
DEBUG5:  00000: mppTxnOptions DefaultXactIsoLevel = READ COMMITTED, DefaultXactReadOnly = false, XactIsoLevel = READ COMMITTED, XactReadOnly = false.    
LOCATION:  mppTxnOptions, cdbtm.c:1690    
DEBUG5:  00000: mppTxnOptions txnOptions = 0x2, needTwoPhase = false, explicitBegin = false, isoLevel = READ COMMITTED, readOnly = false.    
LOCATION:  mppTxnOptions, cdbtm.c:1712    
DEBUG5:  00000: qdSerializeDtxContextInfo using LatestSnapshot    
LOCATION:  qdSerializeDtxContextInfo, cdbdisp_dtx.c:242    
DEBUG5:  00000: [Distributed Snapshot #1289] *QD Use Latest* currcid = 0 (gxid = 1386, 'Master Distributed-Capable')    
LOCATION:  qdSerializeDtxContextInfo, cdbdisp_dtx.c:250    
DEBUG5:  00000: DtxContextInfo_CreateOnMaster: created dtxcontext with dxid 1386/1386 nestingLevel 1 segmateSync 1/1 (current/cached)    
LOCATION:  DtxContextInfo_CreateOnMaster, cdbdtxcontextinfo.c:84    
DEBUG5:  00000: DistributedSnapshot_Copy target maxCount 1000, inProgressXidArray 0x3c88bb0, and source maxCount 1000, count 0, inProgressXidArray 0x3c4ef00    
LOCATION:  DistributedSnapshot_Copy, cdbdistributedsnapshot.c:373    
DEBUG5:  00000: updateSharedLocalSnapshot for DistributedTransactionContext = 'Master Distributed-Capable' passed local snapshot (xmin: 7159 xmax: 7159 xcnt: 0) curcid: 0    
LOCATION:  updateSharedLocalSnapshot, procarray.c:820    
DEBUG5:  00000: updateSharedLocalSnapshot: combocidsize is now 0 max 256 segmateSync 1->1    
LOCATION:  updateSharedLocalSnapshot, procarray.c:850    
DEBUG5:  00000: Master Distributed-Capable setting shared xid 0 -> 0    
LOCATION:  SetSharedTransactionId_writer, xact.c:2200    
DEBUG5:  00000: updateSharedLocalSnapshot for DistributedTransactionContext = 'Master Distributed-Capable' setting shared local snapshot xid = 0 (xmin: 7159 xmax: 7159 xcnt: 0) curcid: 0, QDxid = 1386, QDcid = 0    
LOCATION:  updateSharedLocalSnapshot, procarray.c:870    
DEBUG5:  00000: [Distributed Snapshot #0] *Writer Set Shared* gxid 1386, currcid 0 (gxid = 1386, slot #44, 'qdSerializeDtxContextInfo', 'Master Distributed-Capable')    
LOCATION:  updateSharedLocalSnapshot, procarray.c:880    
DEBUG5:  00000: DtxContextInfo_SerializeSize is returning size = 76    
LOCATION:  DtxContextInfo_SerializeSize, cdbdtxcontextinfo.c:166    
DEBUG3:  00000: DtxContextInfo_Serialize distributedTimeStamp 1535334693, distributedXid = 1386, curcid 0 nestingLevel 1 segmateSync 1    
LOCATION:  DtxContextInfo_Serialize, cdbdtxcontextinfo.c:202    
DEBUG5:  00000: qdSerializeDtxContextInfo (called by cdbdisp_buildPlanQueryParms) returning a snapshot of 76 bytes (ptr is Non-NULL)    
LOCATION:  qdSerializeDtxContextInfo, cdbdisp_dtx.c:314    
DEBUG2:  00000: add icid 6 cid 48 status 1    
LOCATION:  addCursorIcEntry, ic_udpifc.c:937    
DEBUG1:  00000: Exec skip a motion recv, current slice id 0, mstype 2    
LOCATION:  ExecSliceDependencyNode, execProcnode.c:833    
DEBUG3:  00000: In prepareRxConnForRead: conn 0x3ee3718, q_head 0 q_tail 1 q_size 1    
LOCATION:  prepareRxConnForRead, ic_udpifc.c:3610    
DEBUG2:  00000: receiveChunksUDPIFC: non-directed rx woke on route 0    
LOCATION:  receiveChunksUDPIFC, ic_udpifc.c:3665    
DEBUG2:  00000: got data with length 88    
LOCATION:  receiveChunksUDPIFC, ic_udpifc.c:3677    
DEBUG5:  00000: First char: 'M'; gp_role = 'execute'.  (seg0 slice1 127.0.0.1:25432 pid=18488)    
LOCATION:  PostgresMain, postgres.c:4921    
DEBUG1:  00000: Message type M received by from libpq, len = 706  (seg0 slice1 127.0.0.1:25432 pid=18488)    
LOCATION:  PostgresMain, postgres.c:5000    
DEBUG5:  00000: DtxContextInfo_Deserialize serializedDtxContextInfolen = 76.  (seg0 slice1 127.0.0.1:25432 pid=18488)    
LOCATION:  DtxContextInfo_Deserialize, cdbdtxcontextinfo.c:348    
DEBUG3:  00000: DtxContextInfo_Deserialize distributedTimeStamp 1535334693, distributedXid = 1386, curcid 0 nestingLevel 1 segmateSync 1 as WRITER  (seg0 slice1 127.0.0.1:25432 pid=18488)    
LOCATION:  DtxContextInfo_Deserialize, cdbdtxcontextinfo.c:385    
DEBUG5:  00000: MPP dispatched stmt from QD: explain analyze select count(*) from t where id=1;.  (seg0 slice1 127.0.0.1:25432 pid=18488)    
LOCATION:  PostgresMain, postgres.c:5079    
DEBUG5:  00000: setupQEDtxContext intermediate result: isEntryDbSingleton = false, isWriterQE = true, isReaderQE = false.  (seg0 slice1 127.0.0.1:25432 pid=18488)    
LOCATION:  setupQEDtxContext, cdbtm.c:3595    
DEBUG5:  00000: DistributedSnapshot_Copy target maxCount 0, inProgressXidArray (nil), and source maxCount 1000, count 0, inProgressXidArray 0x450aa40  (seg0 slice1 127.0.0.1:25432 pid=18488)    
LOCATION:  DistributedSnapshot_Copy, cdbdistributedsnapshot.c:373    
DEBUG5:  00000: DtxContextInfo_Copy distributed {timestamp 1535334693, xid 1386}, id = 1535334693-0000001386, command id 0  (seg0 slice1 127.0.0.1:25432 pid=18488)    
LOCATION:  DtxContextInfo_Copy, cdbdtxcontextinfo.c:317    
DEBUG5:  00000: distributed snapshot {timestamp 1535334693, xminAllDistributedSnapshots 1386, snapshot id 1289, xmin 1386, count 0, xmax 1386}  (seg0 slice1 127.0.0.1:25432 pid=18488)    
LOCATION:  DtxContextInfo_Copy, cdbdtxcontextinfo.c:328    
DEBUG5:  00000: setupQEDtxContext final result: DistributedTransactionContext = 'Segment Auto-Commit Implicit'.  (seg0 slice1 127.0.0.1:25432 pid=18488)    
LOCATION:  setupQEDtxContext, cdbtm.c:3728    
DEBUG5:  00000: [Distributed Snapshot #1289] *Set QE* currcid = 0 (gxid = 1386, 'Segment Auto-Commit Implicit')  (seg0 slice1 127.0.0.1:25432 pid=18488)    
LOCATION:  setupQEDtxContext, cdbtm.c:3736    
DEBUG3:  00000: StartTransactionCommand  (seg0 slice1 127.0.0.1:25432 pid=18488)    
LOCATION:  start_xact_command, postgres.c:3187    
DEBUG5:  00000: qExec writer setting distributedXid: 1386 sharedQDxid 1386 (shared xid 0 -> 0) ready false (shared timeStamp = 588741036374830 -> 0)  (seg0 slice1 127.0.0.1:25432 pid=18488)    
LOCATION:  StartTransaction, xact.c:2404    
DEBUG5:  00000: [Distributed Snapshot #0] *StartTransaction* (gxid = 1386, xid = 0, 'Segment Auto-Commit Implicit')  (seg0 slice1 127.0.0.1:25432 pid=18488)    
LOCATION:  StartTransaction, xact.c:2446    
DEBUG3:  00000: StartTransaction  (seg0 slice1 127.0.0.1:25432 pid=18488)    
LOCATION:  ShowTransactionState, xact.c:5656    
DEBUG3:  00000: name: unnamed; blockState:       DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:  (seg0 slice1 127.0.0.1:25432 pid=18488)    
LOCATION:  ShowTransactionStateRec, xact.c:5694    
DEBUG5:  00000: StartTransaction in DTX Context = 'Segment Auto-Commit Implicit', distributed transaction {timestamp 1535334693, xid 911} for local xid 0  (seg0 slice1 127.0.0.1:25432 pid=18488)    
LOCATION:  StartTransaction, xact.c:2531    
DEBUG2:  00000: Current nice level of the process: 0  (seg0 slice1 127.0.0.1:25432 pid=18488)    
LOCATION:  renice_current_process, postgres.c:274    
DEBUG2:  00000: Reniced process to level 19  (seg0 slice1 127.0.0.1:25432 pid=18488)    
LOCATION:  renice_current_process, postgres.c:292    
DEBUG5:  00000: GetSnapshotData maxCount 0, inProgressEntryArray (nil)  (seg0 slice1 127.0.0.1:25432 pid=18488)    
LOCATION:  GetSnapshotData, procarray.c:1108    
DEBUG5:  00000: GetSnapshotData serializable true, xmin 0  (seg0 slice1 127.0.0.1:25432 pid=18488)    
LOCATION:  GetSnapshotData, procarray.c:1342    
DEBUG5:  00000: GetSnapshotData setting globalxmin and xmin to 106178  (seg0 slice1 127.0.0.1:25432 pid=18488)    
LOCATION:  GetSnapshotData, procarray.c:1363    
DEBUG5:  00000: FillInDistributedSnapshot DTX Context = 'Segment Auto-Commit Implicit'  (seg0 slice1 127.0.0.1:25432 pid=18488)    
LOCATION:  FillInDistributedSnapshot, procarray.c:926    
DEBUG5:  00000: DistributedSnapshot_Copy target maxCount 1000, inProgressXidArray 0x4518e40, and source maxCount 1000, count 0, inProgressXidArray 0x450b9f0  (seg0 slice1 127.0.0.1:25432 pid=18488)    
LOCATION:  DistributedSnapshot_Copy, cdbdistributedsnapshot.c:373    
DEBUG5:  00000: updateSharedLocalSnapshot for DistributedTransactionContext = 'Segment Auto-Commit Implicit' passed local snapshot (xmin: 106178 xmax: 106178 xcnt: 0) curcid: 0  (seg0 slice1 127.0.0.1:25432 pid=18488)    
LOCATION:  updateSharedLocalSnapshot, procarray.c:820    
DEBUG5:  00000: updateSharedLocalSnapshot: combocidsize is now 0 max 256 segmateSync 0->1  (seg0 slice1 127.0.0.1:25432 pid=18488)    
LOCATION:  updateSharedLocalSnapshot, procarray.c:850    
DEBUG5:  00000: Segment Auto-Commit Implicit setting shared xid 0 -> 0  (seg0 slice1 127.0.0.1:25432 pid=18488)    
LOCATION:  SetSharedTransactionId_writer, xact.c:2200    
DEBUG5:  00000: updateSharedLocalSnapshot for DistributedTransactionContext = 'Segment Auto-Commit Implicit' setting shared local snapshot xid = 0 (xmin: 106178 xmax: 106178 xcnt: 0) curcid: 0, QDxid = 1386, QDcid = 0  (seg0 slice1 127.0.0.1:25432 pid=18488)    
LOCATION:  updateSharedLocalSnapshot, procarray.c:870    
DEBUG5:  00000: [Distributed Snapshot #1289] *Writer Set Shared* gxid 1386, currcid 0 (gxid = 1386, slot #44, 'GetSnapshotData', 'Segment Auto-Commit Implicit')  (seg0 slice1 127.0.0.1:25432 pid=18488)    
LOCATION:  updateSharedLocalSnapshot, procarray.c:880    
DEBUG5:  00000: GetSnapshotData(): WRITER currentcommandid 0 curcid 0 segmatesync 1  (seg0 slice1 127.0.0.1:25432 pid=18488)    
LOCATION:  GetSnapshotData, procarray.c:1532    
DEBUG1:  00000: Inserted entry for query (sessionid=44, commandcnt=48)  (seg0 slice1 127.0.0.1:25432 pid=18488)    
LOCATION:  WorkfileQueryspace_InitEntry, workfile_queryspace.c:299    
DEBUG1:  00000: GetSockAddr socket ai_family 2 ai_socktype 2 ai_protocol 17 for 127.0.0.1  (seg0 slice1 127.0.0.1:25432 pid=18488)    
LOCATION:  getSockAddr, ic_udpifc.c:2731    
DEBUG1:  00000: We are inet6, remote is inet.  Converting to v4 mapped address.  (seg0 slice1 127.0.0.1:25432 pid=18488)    
LOCATION:  setupOutgoingUDPConnection, ic_udpifc.c:2810    
DEBUG1:  00000: Exec process a motion send, current slice id 1, mstype 1  (seg0 slice1 127.0.0.1:25432 pid=18488)    
LOCATION:  ExecSliceDependencyNode, execProcnode.c:837    
DEBUG1:  00000: Interconnect seg0 slice1 cleanup state: force; setup was completed  (seg0 slice1 127.0.0.1:25432 pid=18488)    
LOCATION:  TeardownUDPIFCInterconnect_Internal, ic_udpifc.c:3335    
DEBUG1:  00000: Interconnect State: isSender 1 isReceiver 0 snd_queue_depth 2 recv_queue_depth 4 Gp_max_packet_size 8192 UNACK_QUEUE_RING_SLOTS_NUM 2000 TIMER_SPAN 5000 DEFAULT_RTT 20000 forceEOS 1, gp_interconnect_id 6 ic_id_last_teardown 6 snd_buffer_pool.count 0 snd_buffer_pool.maxCount 0 snd_sock_bufsize 2097152 recv_sock_bufsize 2097152 snd_pkt_count 1 retransmits 0 crc_errors 0 recv_pkt_count 0 recv_ack_num 1 recv_queue_size_avg -nan capacity_avg -nan freebuf_avg 2.000000 mismatch_pkt_num 0 disordered_pkt_num 0 duplicated_pkt_num 0 rtt/dev [17511/4354, 17511.000000/4354.000000, 17511/4354]  cwnd 2.000000 status_query_msg_num 0  (seg0 slice1 127.0.0.1:25432 pid=18488)    
LOCATION:  TeardownUDPIFCInterconnect_Internal, ic_udpifc.c:3546    
DEBUG1:  00000: TeardownUDPIFCInterconnect successful  (seg0 slice1 127.0.0.1:25432 pid=18488)    
LOCATION:  TeardownUDPIFCInterconnect_Internal, ic_udpifc.c:3570    
DEBUG1:  00000: Deleted entry for query (sessionid=44, commandcnt=48)  (seg0 slice1 127.0.0.1:25432 pid=18488)    
LOCATION:  WorkfileQueryspace_ReleaseEntry, workfile_queryspace.c:345    
DEBUG3:  00000: CommitTransactionCommand  (seg0 slice1 127.0.0.1:25432 pid=18488)    
LOCATION:  finish_xact_command, postgres.c:3211    
DEBUG3:  00000: CommitTransaction  (seg0 slice1 127.0.0.1:25432 pid=18488)    
LOCATION:  ShowTransactionState, xact.c:5656    
DEBUG3:  00000: name: unnamed; blockState:       STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:  (seg0 slice1 127.0.0.1:25432 pid=18488)    
LOCATION:  ShowTransactionStateRec, xact.c:5694    
DEBUG5:  00000: prepareDtxTransaction nothing to do (DistributedTransactionContext = 'Segment Auto-Commit Implicit')  (seg0 slice1 127.0.0.1:25432 pid=18488)    
LOCATION:  prepareDtxTransaction, cdbtm.c:1088    
DEBUG5:  00000: notifyCommittedDtxTransaction nothing to do (DistributedTransactionContext = 'Segment Auto-Commit Implicit')  (seg0 slice1 127.0.0.1:25432 pid=18488)    
LOCATION:  notifyCommittedDtxTransactionIsNeeded, cdbtm.c:340    
DEBUG5:  00000: finishDistributedTransactionContext called to change DistributedTransactionContext from Segment Auto-Commit Implicit to Local Only (caller = CommitTransaction, gxid = 1386)  (seg0 slice1 127.0.0.1:25432 pid=18488)    
LOCATION:  finishDistributedTransactionContext, cdbtm.c:3764    
DEBUG1:  00000: Interconnect State: isSender 0 isReceiver 1 snd_queue_depth 2 recv_queue_depth 4 Gp_max_packet_size 8192 UNACK_QUEUE_RING_SLOTS_NUM 2000 TIMER_SPAN 5000 DEFAULT_RTT 20000 forceEOS 0, gp_interconnect_id 6 ic_id_last_teardown 0 snd_buffer_pool.count 0 snd_buffer_pool.maxCount 0 snd_sock_bufsize 2097152 recv_sock_bufsize 2097152 snd_pkt_count 0 retransmits 0 crc_errors 0 recv_pkt_count 1 recv_ack_num 0 recv_queue_size_avg 0.000000 capacity_avg -nan freebuf_avg -nan mismatch_pkt_num 0 disordered_pkt_num 0 duplicated_pkt_num 0 rtt/dev [0/0, 0.000000/0.000000, 0/0]  cwnd 0.000000 status_query_msg_num 0    
LOCATION:  TeardownUDPIFCInterconnect_Internal, ic_udpifc.c:3546    
DEBUG1:  00000: TeardownUDPIFCInterconnect successful    
LOCATION:  TeardownUDPIFCInterconnect_Internal, ic_udpifc.c:3570    
DEBUG1:  00000: Deleted entry for query (sessionid=44, commandcnt=48)    
LOCATION:  WorkfileQueryspace_ReleaseEntry, workfile_queryspace.c:345    
DEBUG3:  00000: CommitTransactionCommand    
LOCATION:  finish_xact_command, postgres.c:3211    
DEBUG3:  00000: CommitTransaction    
LOCATION:  ShowTransactionState, xact.c:5656    
DEBUG3:  00000: name: unnamed; blockState:       STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:    
LOCATION:  ShowTransactionStateRec, xact.c:5694    
DEBUG5:  00000: prepareDtxTransaction ignoring not distributed gid = 1535334693-0000001386    
LOCATION:  prepareDtxTransaction, cdbtm.c:1102    
DEBUG5:  00000: releaseGxact called for gid = 1535334693-0000001386 (index = 22)    
LOCATION:  releaseGxact_UnderLocks, cdbtm.c:2617    
DEBUG5:  00000: notifyCommittedDtxTransaction nothing to do (currentGxact == NULL)    
LOCATION:  notifyCommittedDtxTransactionIsNeeded, cdbtm.c:346    
DEBUG5:  00000: finishDistributedTransactionContext called to change DistributedTransactionContext from Master Distributed-Capable to Local Only (caller = CommitTransaction, gxid = 0)    
LOCATION:  finishDistributedTransactionContext, cdbtm.c:3764    
                                                   QUERY PLAN                                                        
-----------------------------------------------------------------------------------------------------------------    
 Aggregate  (cost=1.07..1.08 rows=1 width=8)    
   Rows out:  1 rows with 0.004 ms to first row, 0.005 ms to end, start offset by 9.489 ms.    
   ->  Gather Motion 1:1  (slice1; segments: 1)  (cost=1.02..1.06 rows=1 width=8)    
         Rows out:  1 rows at destination with 2.691 ms to first row, 8.666 ms to end, start offset by 9.494 ms.    
         ->  Aggregate  (cost=1.02..1.03 rows=1 width=8)    
               Rows out:  1 rows with 0.008 ms to end, start offset by 12 ms.    
               ->  Seq Scan on t  (cost=0.00..1.01 rows=1 width=0)    
                     Filter: id = 1    
                     Rows out:  0 rows with 5.426 ms to end, start offset by 12 ms.    
 Slice statistics:    
   (slice0)    Executor memory: 373K bytes.    
   (slice1)    Executor memory: 334K bytes (seg0).    
 Statement statistics:    
   Memory used: 128000K bytes    
 Optimizer status: legacy query optimizer    
 Total runtime: 18.639 ms    
(16 rows)    

Citus

1、 非分布键过滤,非分布键分组聚合

postgres=# explain select max(id) from test where info='a' group by crt_time;    
DEBUG:  StartTransaction(1) name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0    
DEBUG:  generated sql query for task 1    
DETAIL:  query string: "SELECT max(id) AS max, crt_time AS worker_column_2 FROM test_104508 test WHERE (info OPERATOR(pg_catalog.=) 'a'::text) GROUP BY crt_time"    
DEBUG:  generated sql query for task 2    
DETAIL:  query string: "SELECT max(id) AS max, crt_time AS worker_column_2 FROM test_104509 test WHERE (info OPERATOR(pg_catalog.=) 'a'::text) GROUP BY crt_time"    
DEBUG:  generated sql query for task 3    
DETAIL:  query string: "SELECT max(id) AS max, crt_time AS worker_column_2 FROM test_104510 test WHERE (info OPERATOR(pg_catalog.=) 'a'::text) GROUP BY crt_time"    
......    
DEBUG:  generated sql query for task 126    
DETAIL:  query string: "SELECT max(id) AS max, crt_time AS worker_column_2 FROM test_104633 test WHERE (info OPERATOR(pg_catalog.=) 'a'::text) GROUP BY crt_time"    
DEBUG:  generated sql query for task 127    
DETAIL:  query string: "SELECT max(id) AS max, crt_time AS worker_column_2 FROM test_104634 test WHERE (info OPERATOR(pg_catalog.=) 'a'::text) GROUP BY crt_time"    
DEBUG:  generated sql query for task 128    
DETAIL:  query string: "SELECT max(id) AS max, crt_time AS worker_column_2 FROM test_104635 test WHERE (info OPERATOR(pg_catalog.=) 'a'::text) GROUP BY crt_time"    
DEBUG:  assigned task 1 to node xxx.224:1921    
DEBUG:  assigned task 2 to node xxx.225:1921    
DEBUG:  assigned task 3 to node xxx.226:1921    
......    
DEBUG:  assigned task 126 to node xxx.230:1921    
DEBUG:  assigned task 127 to node xxx.231:1921    
DEBUG:  assigned task 128 to node xxx.232:1921    
DEBUG:  CommitTransaction(1) name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0    
                                           QUERY PLAN                                               
------------------------------------------------------------------------------------------------    
 HashAggregate  (cost=0.00..0.00 rows=0 width=0)    
   Group Key: remote_scan.worker_column_2    
   ->  Custom Scan (Citus Real-Time)  (cost=0.00..0.00 rows=0 width=0)    
         Task Count: 128    
         Tasks Shown: One of 128    
         ->  Task    
               Node: host=xxx.224 port=1921 dbname=postgres    
               ->  GroupAggregate  (cost=24.20..24.31 rows=6 width=12)    
                     Group Key: crt_time    
                     ->  Sort  (cost=24.20..24.22 rows=6 width=12)    
                           Sort Key: crt_time    
                           ->  Seq Scan on test_104508 test  (cost=0.00..24.12 rows=6 width=12)    
                                 Filter: (info = 'a'::text)    
(13 rows)    
    
Time: 96.372 ms    

2、 分布键查询

postgres=# \set VERBOSITY verbose    
postgres=# explain (analyze,verbose,timing,costs,buffers) select * from test where id=1;    
    
DEBUG:  00000: StartTransaction(1) name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0    
LOCATION:  ShowTransactionStateRec, xact.c:5022    
DEBUG:  00000: Creating router plan    
LOCATION:  CreateSingleTaskRouterPlan, multi_router_planner.c:268    
DEBUG:  00000: Plan is router executable    
DETAIL:  distribution column value: 1    
LOCATION:  JobExecutorType, multi_server_executor.c:70    
DEBUG:  00000: CommitTransaction(1) name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0    
LOCATION:  ShowTransactionStateRec, xact.c:5022    
                                                                      QUERY PLAN                                                                           
-------------------------------------------------------------------------------------------------------------------------------------------------------    
 Custom Scan (Citus Router)  (cost=0.00..0.00 rows=0 width=0) (actual time=7.732..7.733 rows=1 loops=1)    
   Output: remote_scan.id, remote_scan.info, remote_scan.crt_time    
   Task Count: 1    
   Tasks Shown: All    
   ->  Task    
         Node: host=xxx.232 port=1921 dbname=postgres    
         ->  Index Scan using test_pkey_104515 on public.test_104515 test  (cost=0.15..2.37 rows=1 width=44) (actual time=0.012..0.013 rows=1 loops=1)    
               Output: id, info, crt_time    
               Index Cond: (test.id = 1)    
               Buffers: shared hit=2    
             Planning time: 0.037 ms    
             Execution time: 0.025 ms    
 Planning time: 1.693 ms    
 Execution time: 7.756 ms    
(14 rows)    

3、 不支持的聚合函数

postgres=# select stddev(id) from test where info='a';    
DEBUG:  00000: StartTransaction(1) name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0    
LOCATION:  ShowTransactionStateRec, xact.c:5022    
ERROR:  XX000: unsupported aggregate function stddev    
LOCATION:  GetAggregateType, multi_logical_optimizer.c:2915    
相关实践学习
使用PolarDB和ECS搭建门户网站
本场景主要介绍基于PolarDB和ECS实现搭建门户网站。
阿里云数据库产品家族及特性
阿里云智能数据库产品团队一直致力于不断健全产品体系,提升产品性能,打磨产品功能,从而帮助客户实现更加极致的弹性能力、具备更强的扩展能力、并利用云设施进一步降低企业成本。以云原生+分布式为核心技术抓手,打造以自研的在线事务型(OLTP)数据库Polar DB和在线分析型(OLAP)数据库Analytic DB为代表的新一代企业级云原生数据库产品体系, 结合NoSQL数据库、数据库生态工具、云原生智能化数据库管控平台,为阿里巴巴经济体以及各个行业的企业客户和开发者提供从公共云到混合云再到私有云的完整解决方案,提供基于云基础设施进行数据从处理、到存储、再到计算与分析的一体化解决方案。本节课带你了解阿里云数据库产品家族及特性。
目录
相关文章
|
7月前
|
SQL Oracle 关系型数据库
实时计算 Flink版操作报错之往GREENPLUM 6 写数据,用postgresql-42.2.9.jar 报 ON CONFLICT (uuid) DO UPDATE SET 语法有问题。怎么解决
在使用实时计算Flink版过程中,可能会遇到各种错误,了解这些错误的原因及解决方法对于高效排错至关重要。针对具体问题,查看Flink的日志是关键,它们通常会提供更详细的错误信息和堆栈跟踪,有助于定位问题。此外,Flink社区文档和官方论坛也是寻求帮助的好去处。以下是一些常见的操作报错及其可能的原因与解决策略。
|
1月前
|
关系型数据库 分布式数据库 数据库
PostgreSQL+Citus分布式数据库
PostgreSQL+Citus分布式数据库
65 15
|
2月前
|
SQL 关系型数据库 分布式数据库
Citus 简介,将 Postgres 转换为分布式数据库
【10月更文挑战第4天】Citus 简介,将 Postgres 转换为分布式数据库
106 4
|
6月前
|
SQL 关系型数据库 PostgreSQL
PostgreSQL和greenplum的copy命令可以添加字段吗?
【6月更文挑战第5天】PostgreSQL和greenplum的copy命令可以添加字段吗?
98 3
|
6月前
|
监控 关系型数据库 数据库
PostgreSQL和greenplum的copy命令如何使用?
【6月更文挑战第5天】PostgreSQL和greenplum的copy命令如何使用?
187 2
|
7月前
|
监控 关系型数据库 Java
SpringBoot【集成 01】Druid+Dynamic+Greenplum(实际上用的是PostgreSQL的驱动)及 dbType not support 问题处理(附hikari相关配置)
SpringBoot【集成 01】Druid+Dynamic+Greenplum(实际上用的是PostgreSQL的驱动)及 dbType not support 问题处理(附hikari相关配置)
350 0
|
存储 SQL 关系型数据库
PostgreSQL技术大讲堂 - 第29讲:执行计划与成本估算
从零开始学PostgreSQL技术大讲堂 - 第29讲:执行计划与成本估算
201 1
|
存储 SQL 分布式计算
分布式图计算如何实现?带你一窥图计算执行计划
分布式图计算如何实现?带你一窥图计算执行计划
分布式图计算如何实现?带你一窥图计算执行计划
|
算法 关系型数据库 PostgreSQL
PostgreSQL/GreenPlum Merge Inner Join解密
PostgreSQL/GreenPlum Merge Inner Join解密
88 0
PostgreSQL/GreenPlum Merge Inner Join解密
|
关系型数据库 PostgreSQL
PostgreSQL执行计划explain
PostgreSQL执行计划explain
143 0

相关产品

  • 云原生数据库 PolarDB
  • 云数据库 RDS PostgreSQL 版