-
Notifications
You must be signed in to change notification settings - Fork 218
Import gp_relsizes_stats extention from Greenplum #1757
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Vlasdislav
wants to merge
1
commit into
apache:main
Choose a base branch
from
Vlasdislav:gp_relsizes_stats
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,192 @@ | ||
| --- | ||
| Language: Cpp | ||
| # BasedOnStyle: LLVM | ||
| AccessModifierOffset: -2 | ||
| AlignAfterOpenBracket: Align | ||
| AlignArrayOfStructures: None | ||
| AlignConsecutiveMacros: None | ||
| AlignConsecutiveAssignments: None | ||
| AlignConsecutiveBitFields: None | ||
| AlignConsecutiveDeclarations: None | ||
| AlignEscapedNewlines: Right | ||
| AlignOperands: Align | ||
| AlignTrailingComments: true | ||
| AllowAllArgumentsOnNextLine: true | ||
| AllowAllParametersOfDeclarationOnNextLine: true | ||
| AllowShortEnumsOnASingleLine: true | ||
| AllowShortBlocksOnASingleLine: Never | ||
| AllowShortCaseLabelsOnASingleLine: false | ||
| AllowShortFunctionsOnASingleLine: All | ||
| AllowShortLambdasOnASingleLine: All | ||
| AllowShortIfStatementsOnASingleLine: Never | ||
| AllowShortLoopsOnASingleLine: false | ||
| AlwaysBreakAfterDefinitionReturnType: None | ||
| AlwaysBreakAfterReturnType: None | ||
| AlwaysBreakBeforeMultilineStrings: false | ||
| AlwaysBreakTemplateDeclarations: MultiLine | ||
| AttributeMacros: | ||
| - __capability | ||
| BinPackArguments: true | ||
| BinPackParameters: true | ||
| BraceWrapping: | ||
| AfterCaseLabel: false | ||
| AfterClass: false | ||
| AfterControlStatement: Never | ||
| AfterEnum: false | ||
| AfterFunction: false | ||
| AfterNamespace: false | ||
| AfterObjCDeclaration: false | ||
| AfterStruct: false | ||
| AfterUnion: false | ||
| AfterExternBlock: false | ||
| BeforeCatch: false | ||
| BeforeElse: false | ||
| BeforeLambdaBody: false | ||
| BeforeWhile: false | ||
| IndentBraces: false | ||
| SplitEmptyFunction: true | ||
| SplitEmptyRecord: true | ||
| SplitEmptyNamespace: true | ||
| BreakBeforeBinaryOperators: None | ||
| BreakBeforeConceptDeclarations: true | ||
| BreakBeforeBraces: Attach | ||
| BreakBeforeInheritanceComma: false | ||
| BreakInheritanceList: BeforeColon | ||
| BreakBeforeTernaryOperators: true | ||
| BreakConstructorInitializersBeforeComma: false | ||
| BreakConstructorInitializers: BeforeColon | ||
| BreakAfterJavaFieldAnnotations: false | ||
| BreakStringLiterals: true | ||
| ColumnLimit: 120 | ||
| CommentPragmas: '^ IWYU pragma:' | ||
| QualifierAlignment: Leave | ||
| CompactNamespaces: false | ||
| ConstructorInitializerIndentWidth: 4 | ||
| ContinuationIndentWidth: 4 | ||
| Cpp11BracedListStyle: true | ||
| DeriveLineEnding: true | ||
| DerivePointerAlignment: false | ||
| DisableFormat: false | ||
| EmptyLineAfterAccessModifier: Never | ||
| EmptyLineBeforeAccessModifier: LogicalBlock | ||
| ExperimentalAutoDetectBinPacking: false | ||
| PackConstructorInitializers: BinPack | ||
| BasedOnStyle: '' | ||
| ConstructorInitializerAllOnOneLineOrOnePerLine: false | ||
| AllowAllConstructorInitializersOnNextLine: true | ||
| FixNamespaceComments: true | ||
| ForEachMacros: | ||
| - foreach | ||
| - Q_FOREACH | ||
| - BOOST_FOREACH | ||
| IfMacros: | ||
| - KJ_IF_MAYBE | ||
| IncludeBlocks: Preserve | ||
| IncludeCategories: | ||
| - Regex: '^"(llvm|llvm-c|clang|clang-c)/' | ||
| Priority: 2 | ||
| SortPriority: 0 | ||
| CaseSensitive: false | ||
| - Regex: '^(<|"(gtest|gmock|isl|json)/)' | ||
| Priority: 3 | ||
| SortPriority: 0 | ||
| CaseSensitive: false | ||
| - Regex: '.*' | ||
| Priority: 1 | ||
| SortPriority: 0 | ||
| CaseSensitive: false | ||
| IncludeIsMainRegex: '(Test)?$' | ||
| IncludeIsMainSourceRegex: '' | ||
| IndentAccessModifiers: false | ||
| IndentCaseLabels: false | ||
| IndentCaseBlocks: false | ||
| IndentGotoLabels: true | ||
| IndentPPDirectives: None | ||
| IndentExternBlock: AfterExternBlock | ||
| IndentRequires: false | ||
| IndentWidth: 4 | ||
| IndentWrappedFunctionNames: false | ||
| InsertTrailingCommas: None | ||
| JavaScriptQuotes: Leave | ||
| JavaScriptWrapImports: true | ||
| KeepEmptyLinesAtTheStartOfBlocks: true | ||
| LambdaBodyIndentation: Signature | ||
| MacroBlockBegin: '' | ||
| MacroBlockEnd: '' | ||
| MaxEmptyLinesToKeep: 1 | ||
| NamespaceIndentation: None | ||
| ObjCBinPackProtocolList: Auto | ||
| ObjCBlockIndentWidth: 2 | ||
| ObjCBreakBeforeNestedBlockParam: true | ||
| ObjCSpaceAfterProperty: false | ||
| ObjCSpaceBeforeProtocolList: true | ||
| PenaltyBreakAssignment: 2 | ||
| PenaltyBreakBeforeFirstCallParameter: 19 | ||
| PenaltyBreakComment: 300 | ||
| PenaltyBreakFirstLessLess: 120 | ||
| PenaltyBreakOpenParenthesis: 0 | ||
| PenaltyBreakString: 1000 | ||
| PenaltyBreakTemplateDeclaration: 10 | ||
| PenaltyExcessCharacter: 1000000 | ||
| PenaltyReturnTypeOnItsOwnLine: 60 | ||
| PenaltyIndentedWhitespace: 0 | ||
| PointerAlignment: Right | ||
| PPIndentWidth: -1 | ||
| ReferenceAlignment: Pointer | ||
| ReflowComments: true | ||
| RemoveBracesLLVM: false | ||
| SeparateDefinitionBlocks: Leave | ||
| ShortNamespaceLines: 1 | ||
| SortIncludes: CaseSensitive | ||
| SortJavaStaticImport: Before | ||
| SortUsingDeclarations: true | ||
| SpaceAfterCStyleCast: false | ||
| SpaceAfterLogicalNot: false | ||
| SpaceAfterTemplateKeyword: true | ||
| SpaceBeforeAssignmentOperators: true | ||
| SpaceBeforeCaseColon: false | ||
| SpaceBeforeCpp11BracedList: false | ||
| SpaceBeforeCtorInitializerColon: true | ||
| SpaceBeforeInheritanceColon: true | ||
| SpaceBeforeParens: ControlStatements | ||
| SpaceBeforeParensOptions: | ||
| AfterControlStatements: true | ||
| AfterForeachMacros: true | ||
| AfterFunctionDefinitionName: false | ||
| AfterFunctionDeclarationName: false | ||
| AfterIfMacros: true | ||
| AfterOverloadedOperator: false | ||
| BeforeNonEmptyParentheses: false | ||
| SpaceAroundPointerQualifiers: Default | ||
| SpaceBeforeRangeBasedForLoopColon: true | ||
| SpaceInEmptyBlock: false | ||
| SpaceInEmptyParentheses: false | ||
| SpacesBeforeTrailingComments: 1 | ||
| SpacesInAngles: Never | ||
| SpacesInConditionalStatement: false | ||
| SpacesInContainerLiterals: true | ||
| SpacesInCStyleCastParentheses: false | ||
| SpacesInLineCommentPrefix: | ||
| Minimum: 1 | ||
| Maximum: -1 | ||
| SpacesInParentheses: false | ||
| SpacesInSquareBrackets: false | ||
| SpaceBeforeSquareBrackets: false | ||
| BitFieldColonSpacing: Both | ||
| Standard: Latest | ||
| StatementAttributeLikeMacros: | ||
| - Q_EMIT | ||
| StatementMacros: | ||
| - Q_UNUSED | ||
| - QT_REQUIRE_VERSION | ||
| TabWidth: 8 | ||
| UseCRLF: false | ||
| UseTab: Never | ||
| WhitespaceSensitiveMacros: | ||
| - STRINGIZE | ||
| - PP_STRINGIZE | ||
| - BOOST_PP_STRINGIZE | ||
| - NS_SWIFT_NAME | ||
| - CF_SWIFT_NAME | ||
| ... | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| *.o | ||
| *.so | ||
| src/protos/ | ||
| results | ||
| .vscode | ||
| compile_commands.json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| #------------------------------------------------------------------------- | ||
| # | ||
| # Makefile for gp_relsizes_stats extension. | ||
| # | ||
| # By default this Makefile is intended to be included from the surrounding | ||
| # Cloudberry source tree (in-tree build); pass USE_PGXS=1 to build against an | ||
| # already-installed Cloudberry/PostgreSQL using pg_config. | ||
| # | ||
| # IDENTIFICATION | ||
| # gpcontrib/gp_relsizes_stats/Makefile | ||
| # | ||
| #------------------------------------------------------------------------- | ||
|
|
||
| MODULE_big = gp_relsizes_stats | ||
| OBJS = ./src/gp_relsizes_stats.o | ||
| EXTENSION = gp_relsizes_stats | ||
| EXTVERSION = 1.0 | ||
| DATA = $(wildcard sql/*--*.sql) | ||
| REGRESS = grants gp_relsizes_stats | ||
| REGRESS_OPTS = --inputdir=test/ | ||
| PGFILEDESC = "gp_relsizes_stats - an extension to track table on-disc sizes in Cloudberry" | ||
| PG_CXXFLAGS += $(COMMON_CPP_FLAGS) | ||
|
|
||
| # Auto-detect build mode: if we are sitting inside a Cloudberry source tree | ||
| # (i.e. ../../src/Makefile.global is reachable), build in-tree; otherwise fall | ||
| # back to a standalone PGXS build driven by pg_config. USE_PGXS=1 forces PGXS | ||
| # even when an in-tree Makefile.global is available. | ||
| ifeq ($(USE_PGXS),) | ||
| ifeq ($(wildcard ../../src/Makefile.global),) | ||
| USE_PGXS = 1 | ||
| endif | ||
| endif | ||
|
|
||
| ifdef USE_PGXS | ||
| PG_CONFIG ?= pg_config | ||
| PGXS := $(shell $(PG_CONFIG) --pgxs) | ||
| include $(PGXS) | ||
| else | ||
| subdir = gpcontrib/gp_relsizes_stats | ||
| top_builddir = ../.. | ||
| include $(top_builddir)/src/Makefile.global | ||
| include $(top_srcdir)/contrib/contrib-global.mk | ||
| endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| <!-- | ||
| Licensed to the Apache Software Foundation (ASF) under one | ||
| or more contributor license agreements. See the NOTICE file | ||
| distributed with this work for additional information | ||
| regarding copyright ownership. The ASF licenses this file | ||
| to you under the Apache License, Version 2.0 (the | ||
| "License"); you may not use this file except in compliance | ||
| with the License. You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, | ||
| software distributed under the License is distributed on an | ||
| "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| KIND, either express or implied. See the License for the | ||
| specific language governing permissions and limitations | ||
| under the License. | ||
| --> | ||
|
|
||
| # gp_relsizes_stats: Table sizes monitoring tool for Cloudberry | ||
|
|
||
| ### Features | ||
| gp_relsizes_stats is an extension for the Cloudberry database that calculates and stores statistics on the size of files and tables, occupied space on the disks of the master and segment hosts. | ||
|
|
||
| #### Features include | ||
| - BackgroundWorker support for collecting statistics automatically | ||
| - the ability to fine-tune the timeout values between actions, for example, between launches for different databases, or during file processing to distribute the load over time | ||
|
|
||
| ### Supported versions and platforms | ||
| At the moment, the program is being tested only for Cloudberry and Linux. | ||
|
|
||
| ### Installation | ||
| This extension is part of the Cloudberry monorepo under `gpcontrib/gp_relsizes_stats`. | ||
|
|
||
| Build and install from the Cloudberry monorepo root: | ||
| ```bash | ||
| make -C gpcontrib/gp_relsizes_stats | ||
| sudo make -C gpcontrib/gp_relsizes_stats install | ||
| ``` | ||
|
|
||
| ### Configuration | ||
| gp_relsizes_stats configuration parameters: | ||
| | **Parameter** | **Type** | **Default** | **Description** | | ||
| | ---------------- | --------------- | ------------ | ------------ | | ||
| | `gp_relsizes_stats.enabled` | bool | false | Using `gp_relsizes_stats.enabled` you can enable/disable background stats collection for database where extension installed (actually enable/disable background worker which collecting stats).| | ||
| | `gp_relsizes_stats.restart_naptime` | int | 21600000 | Using `gp_relsizes_stats.restart_naptime` you can set naptime between each startup of collecting process. Value set time in milliseconds. Default is equal to 6 hours.| | ||
| | `gp_relsizes_stats.database_naptime` | int | 0 | Using `gp_relsizes_stats.database_naptime` you can set naptime between collecting stats for each databases. Value set time in milliseconds. Default is equal to 0 milliseconds.| | ||
| | `gp_relsizes_stats.file_naptime` | int | 1 | Using `gp_relsizes_stats.file_naptime` you can set naptime between each file stats calculating. Value set time in milliseconds. Default is equal to 1 millisecond.| | ||
|
|
||
| ### Usage | ||
| You can use a background worker to collect statistics, but if you sometimes need to change the format of the settings or if you don't want to collect statistics on a regular basis, you can do so. In these situations, you could set | ||
| ``` | ||
| gp_relsizes_stats.enabled = off | ||
| ``` | ||
|
|
||
| And use the function | ||
| ``` | ||
| relsizes_stats_schema.relsizes_collect_stats_once() | ||
| ``` | ||
| which can be called manually using 'select'. | ||
| It will launch a single statistics collection procedure. | ||
|
|
||
|
|
||
| ### About collected data and tables | ||
| | Name of table | Row description | Description | | ||
| | ------------- | --------------- | ----------- | | ||
| | relsizes_stats_schema.segment_file_sizes | (segment, relfilenode, filepath, size, mtime) | Current size and last modify time of each file of specific relation on specific segment | | ||
| | relsizes_stats_schema.namespace_sizes | (nspname, nspsize) | Current size of namespace | | ||
| | relsizes_stats_schema.table_sizes | (nspname, relname, relsize) | Current size of relation in specific namespace | | ||
| | relsizes_stats_schema.table_sizes_history | (insert_date, nspname, relname, size, mtime) | Size and last modify time of relation in specific namespace with date when information was collected | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # gp_relsizes_stats extension | ||
| comment = 'gp_relsizes_stats - an extension to track table on-disc sizes in cloudberry' | ||
| default_version = '1.0' | ||
| module_pathname = '$libdir/gp_relsizes_stats' | ||
| trusted = true | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I left it as it was in greenplum |
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.