0
点赞
收藏
分享

微信扫一扫

ORCA优化器浅析——IMDRelation Storage type of a relation GP6与GP7对比


ORCA优化器浅析——IMDRelation Storage type of a relation GP6与GP7对比_存储类型


如上图所示IMDRelation作为Interface for relations in the metadata cache,其定义了Storage type of a relation表的存储类型,如下所示:

enum Erelstoragetype {
		ErelstorageHeap,
		ErelstorageAppendOnlyCols,
		ErelstorageAppendOnlyRows,
		ErelstorageAppendOnlyParquet,
		ErelstorageExternal,
		ErelstorageVirtual,
		ErelstorageSentinel
	};

下面是ErelstorageHeap存储类型所涉及到的代码:

  • CTranslatorQueryToDXL::TranslateCTASToDXL Translate a CTAS 设定CDXLLogicalCTAS类的存储类型
  • CTranslatorRelcacheToDXL::RetrieveRelStorageType Get relation storage type根据存储类型字符获取其Erelstoragetype枚举类型
  • CXformUtils::PexprBuildIndexPlan Construct an expression representing a new access path using the given functors for operator constructors and rewritten access path. Non-heap tables not supported for GiST 非heap表不支持GiST判定

下面是ErelstorageAppendOnlyCols存储类型所涉及到的代码:

  • CTranslatorQueryToDXL::GetDXLCtasOptionArray Translate CTAS storage options 根据存储选项判定存储类型
  • CTranslatorRelcacheToDXL::RetrieveRelColumns Get relation columns AO表需要添加系统列
  • CTranslatorRelcacheToDXL::RetrieveRelStorageType Get relation storage type根据存储类型字符获取其Erelstoragetype枚举类型
  • CTableDescriptor::IsAORowOrColTable 判定是否是AO表

下面是ErelstorageAppendOnlyRows存储类型所涉及到的代码:

  • CTranslatorQueryToDXL::GetDXLCtasOptionArray Translate CTAS storage options 根据存储选项判定存储类型
  • CTranslatorRelcacheToDXL::RetrieveRelColumns Get relation columns AO表需要添加系统列
  • CTranslatorRelcacheToDXL::RetrieveRelStorageType Get relation storage type根据存储类型字符获取其Erelstoragetype枚举类型
  • CTableDescriptor::IsAORowOrColTable 判定是否是AO表
  • CUtils::FGeneratePartOid generate part oid 判定InsertSortOnRows
  • CPhysicalDML::FInsertSortOnRows Do we need to sort on insert

下面是ErelstorageAppendOnlyParquet存储类型所涉及到的代码:

  • CTranslatorQueryToDXL::GetDXLCtasOptionArray Translate CTAS storage options 根据存储选项判定存储类型
  • CUtils::FGeneratePartOid generate part oid 判定InsertSortOnParquet
  • CPhysicalDML::FInsertSortOnParquet Do we need to sort on parquet table

下面是ErelstorageExternal存储类型所涉及到的代码:

  • CTranslatorDXLToPlStmt::TranslateDXLTblScan Translates a DXL table scan node into a TableScan node
  • CTranslatorQueryToDXL::TranslateRTEToDXLLogicalGet Returns a CDXLNode representing a from relation range table entry
  • CTranslatorRelcacheToDXL::RetrieveRel Retrieve a relation from the relcache given its metadata id 不为外部表的情况下get partition keys;Retrieve full part constraints partitioned tables with indexes or external partitions, returns NULL for non-partitioned tables
  • CTranslatorRelcacheToDXL::RetrieveRelStorageType Get relation storage type根据存储类型字符获取其Erelstoragetype枚举类型
  • COptTasks::PrintMissingStatsWarning Print warning messages for columns with missing statistics 不为外部表时打印missing statistic信息

下面是ErelstorageVirtual存储类型所涉及到的代码:CTranslatorRelcacheToDXL::RetrieveRelStorageType Get relation storage type根据存储类型字符获取其Erelstoragetype枚举类型。该枚举类型应该是不用的。

GP6与GP7存储类型对比

ORCA优化器浅析——IMDRelation Storage type of a relation GP6与GP7对比_枚举类型_02

enum Erelstoragetype{
		ErelstorageHeap,
		ErelstorageAppendOnlyCols,
		ErelstorageAppendOnlyRows,
		ErelstorageForeign,
		ErelstorageMixedPartitioned,
		ErelstorageCompositeType,
		ErelstorageSentinel
	};

下面是ErelstorageHeap存储类型所涉及到的代码:

  • CTranslatorQueryToDXL::TranslateCTASToDXL Translate a CTAS 设定CDXLLogicalCTAS类的存储类型
  • CTranslatorRelcacheToDXL::RetrieveRelStorageType Get relation storage type
  • CTranslatorRelcacheToDXL::RetrieveStorageTypeForPartitionedTable 如果rel->rd_partdesc->nparts == 0,返回ErelstorageHeap存储类型
  • CXformUtils::PexprBuildIndexPlan Construct an expression representing a new access path using the given functors for operator constructors and rewritten access path. Non-heap tables not supported for GiST 非heap表不支持GiST判定

下面是ErelstorageAppendOnlyCols存储类型所涉及到的代码:

  • CTranslatorQueryToDXL::GetDXLCtasOptionArray Translate CTAS storage options 根据存储选项判定存储类型
  • CTranslatorRelcacheToDXL::RetrieveRelStorageType Get relation storage type根据AM获取其Erelstoragetype枚举类型
  • CTableDescriptor::IsAORowOrColTable 判定是否是AO表

下面是ErelstorageAppendOnlyRows存储类型所涉及到的代码:

  • CTranslatorQueryToDXL::GetDXLCtasOptionArray Translate CTAS storage options 根据存储选项判定存储类型
  • CTranslatorRelcacheToDXL::RetrieveRelStorageType Get relation storage type根据AM获取其Erelstoragetype枚举类型
  • CTableDescriptor::IsAORowOrColTable 判定是否是AO表

下面是ErelstorageForeign存储类型所涉及到的代码:

  • CTranslatorDXLToPlStmt::TranslateDXLTblScan Translates a DXL table scan node into a TableScan node
  • TranslatorQueryToDXL::TranslateRTEToDXLLogicalGet Returns a CDXLNode representing a from relation range table entry 新建CDXLLogicalForeignGet分支
  • CTranslatorRelcacheToDXL::RetrieveRel Retrieve a relation from the relcache given its metadata id. root partitions don’t have a foreign server 重要
  • CTranslatorRelcacheToDXL::RetrieveRelStorageType rel->rd_rel->relkind == RELKIND_FOREIGN_TABLE分支
  • CTranslatorRelcacheToDXL::RetrieveStorageTypeForPartitionedTable for partitioned tables with foreign partitions, we want to ignore the foreign partitions for determining the storage-type (unless all of the partitions are foreign) as we’ll be separating them out to different scans later in CXformExpandDynamicGetWithForeignPartitions
  • CTranslatorUtils::GetTableDescr Create a DXL table descriptor from a GPDB range table entry fall back to the planner for queries on coordinator-only table if they are disabled with Orca
  • CTranslatorUtils::RelContainsForeignPartitions
  • COptTasks::PrintMissingStatsWarning Print warning messages for columns with missing statistics 不为外部表时打印missing statistic信息
  • CTranslatorDXLToExpr::PexprLogicalGet Create a Expr logical get from a DXL logical get store array of foreign partitions

下面是ErelstorageMixedPartitioned存储类型所涉及到的代码:

  • CTranslatorRelcacheToDXL::RetrieveStorageTypeForPartitionedTable mark any partitioned table with supported partitions of mixed storage types, this is more conservative for certain skans (eg: we can’t do an index scan if any partition is ao, we must only do a sequential or bitmap scan)
  • CXformIndexGet2IndexOnlyScan::Exfp 判定possible_ao_table
  • CXformIndexGet2IndexScan::Exfp 判定possible_ao_table
  • CXformUtils::FIndexApplicable Check if an index is applicable given the required, output and scalar expression columns 判定possible_ao_table
  • CXformUtils::PexprBitmapSelectBestIndex Given conjuncts of supported predicates, select the best index and construct a bitmap index path expression. Return unused predicates as residuals 判定possible_ao_table

下面是ErelstorageCompositeType存储类型所涉及到的代码:CTranslatorRelcacheToDXL::RetrieveRelStorageType中对应RELKIND_COMPOSITE_TYPE获取存储类型ErelstorageCompositeType

从上面的对比可以看出AP7将分区表子分区混合存储这种情况单独作为了一种存储类型ErelstorageMixedPartitioned。


举报

相关推荐

0 条评论