Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdcc08d8

Browse files
committed
introduce 'pg_pathman.enable_bounds_cache' GUC, improve memory consumption of function fill_prel_with_partitions()
1 parentced4f8e commitdcc08d8

File tree

9 files changed

+225
-57
lines changed

9 files changed

+225
-57
lines changed

‎expected/pathman_calamity.out

Lines changed: 82 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,8 @@ DROP EXTENSION pg_pathman;
677677
*/
678678
CREATE SCHEMA calamity;
679679
CREATE EXTENSION pg_pathman;
680+
/* Change this setting for code coverage */
681+
SET pg_pathman.enable_bounds_cache = false;
680682
/* check view pathman_cache_stats */
681683
CREATE TABLE calamity.test_pathman_cache_stats(val NUMERIC NOT NULL);
682684
SELECT create_range_partitions('calamity.test_pathman_cache_stats', 'val', 1, 10, 10);
@@ -687,16 +689,89 @@ NOTICE: sequence "test_pathman_cache_stats_seq" does not exist, skipping
687689
(1 row)
688690

689691
SELECT context, entries FROM pathman_cache_stats ORDER BY context;/* OK */
690-
context | entries
691-
-------------------------+---------
692-
maintenance | 0
693-
partition bounds cache |10
694-
partitionparents cache |10
695-
partitionpruning cache | 1
692+
context| entries
693+
--------------------------+---------
694+
maintenance| 0
695+
partition bounds cache| 0
696+
partitiondispatch cache | 1
697+
partitionparents cache|10
696698
(4 rows)
697699

700+
SELECT drop_partitions('calamity.test_pathman_cache_stats');
701+
NOTICE: function calamity.test_pathman_cache_stats_upd_trig_func() does not exist, skipping
702+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_1
703+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_2
704+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_3
705+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_4
706+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_5
707+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_6
708+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_7
709+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_8
710+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_9
711+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_10
712+
drop_partitions
713+
-----------------
714+
10
715+
(1 row)
716+
717+
SELECT context, entries FROM pathman_cache_stats ORDER BY context;/* OK */
718+
context | entries
719+
--------------------------+---------
720+
maintenance | 0
721+
partition bounds cache | 0
722+
partition dispatch cache | 0
723+
partition parents cache | 0
724+
(4 rows)
725+
726+
DROP TABLE calamity.test_pathman_cache_stats;
727+
/* Restore this GUC */
728+
SET pg_pathman.enable_bounds_cache = true;
729+
/* check view pathman_cache_stats (one more time) */
730+
CREATE TABLE calamity.test_pathman_cache_stats(val NUMERIC NOT NULL);
731+
SELECT create_range_partitions('calamity.test_pathman_cache_stats', 'val', 1, 10, 10);
732+
create_range_partitions
733+
-------------------------
734+
10
735+
(1 row)
736+
737+
SELECT context, entries FROM pathman_cache_stats ORDER BY context;/* OK */
738+
context | entries
739+
--------------------------+---------
740+
maintenance | 0
741+
partition bounds cache | 10
742+
partition dispatch cache | 1
743+
partition parents cache | 10
744+
(4 rows)
745+
746+
SELECT drop_partitions('calamity.test_pathman_cache_stats');
747+
NOTICE: function calamity.test_pathman_cache_stats_upd_trig_func() does not exist, skipping
748+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_1
749+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_2
750+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_3
751+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_4
752+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_5
753+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_6
754+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_7
755+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_8
756+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_9
757+
NOTICE: 0 rows copied from calamity.test_pathman_cache_stats_10
758+
drop_partitions
759+
-----------------
760+
10
761+
(1 row)
762+
763+
SELECT context, entries FROM pathman_cache_stats ORDER BY context;/* OK */
764+
context | entries
765+
--------------------------+---------
766+
maintenance | 0
767+
partition bounds cache | 0
768+
partition dispatch cache | 0
769+
partition parents cache | 0
770+
(4 rows)
771+
772+
DROP TABLE calamity.test_pathman_cache_stats;
698773
DROP SCHEMA calamity CASCADE;
699-
NOTICE: drop cascades to12 other objects
774+
NOTICE: drop cascades tosequence calamity.test_pathman_cache_stats_seq
700775
DROP EXTENSION pg_pathman;
701776
/*
702777
* ------------------------------------------

‎sql/pathman_calamity.sql

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,10 +274,27 @@ DROP EXTENSION pg_pathman;
274274
CREATESCHEMAcalamity;
275275
CREATE EXTENSION pg_pathman;
276276

277+
/* Change this setting for code coverage*/
278+
SETpg_pathman.enable_bounds_cache= false;
279+
277280
/* check view pathman_cache_stats*/
278281
CREATETABLEcalamity.test_pathman_cache_stats(valNUMERICNOT NULL);
279282
SELECT create_range_partitions('calamity.test_pathman_cache_stats','val',1,10,10);
280283
SELECT context, entriesFROM pathman_cache_statsORDER BY context;/* OK*/
284+
SELECT drop_partitions('calamity.test_pathman_cache_stats');
285+
SELECT context, entriesFROM pathman_cache_statsORDER BY context;/* OK*/
286+
DROPTABLEcalamity.test_pathman_cache_stats;
287+
288+
/* Restore this GUC*/
289+
SETpg_pathman.enable_bounds_cache= true;
290+
291+
/* check view pathman_cache_stats (one more time)*/
292+
CREATETABLEcalamity.test_pathman_cache_stats(valNUMERICNOT NULL);
293+
SELECT create_range_partitions('calamity.test_pathman_cache_stats','val',1,10,10);
294+
SELECT context, entriesFROM pathman_cache_statsORDER BY context;/* OK*/
295+
SELECT drop_partitions('calamity.test_pathman_cache_stats');
296+
SELECT context, entriesFROM pathman_cache_statsORDER BY context;/* OK*/
297+
DROPTABLEcalamity.test_pathman_cache_stats;
281298

282299
DROPSCHEMA calamity CASCADE;
283300
DROP EXTENSION pg_pathman;

‎src/hooks.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -447,14 +447,16 @@ pg_pathman_enable_assign_hook(bool newval, void *extra)
447447
pg_pathman_init_state.override_copy&&
448448
pg_pathman_enable_runtimeappend&&
449449
pg_pathman_enable_runtime_merge_append&&
450-
pg_pathman_enable_partition_filter))
450+
pg_pathman_enable_partition_filter&&
451+
pg_pathman_enable_bounds_cache))
451452
return;
452453

453-
pg_pathman_init_state.auto_partition=newval;
454-
pg_pathman_init_state.override_copy=newval;
455-
pg_pathman_enable_runtime_merge_append=newval;
456-
pg_pathman_enable_runtimeappend=newval;
457-
pg_pathman_enable_partition_filter=newval;
454+
pg_pathman_init_state.auto_partition=newval;
455+
pg_pathman_init_state.override_copy=newval;
456+
pg_pathman_enable_runtimeappend=newval;
457+
pg_pathman_enable_runtime_merge_append=newval;
458+
pg_pathman_enable_partition_filter=newval;
459+
pg_pathman_enable_bounds_cache=newval;
458460

459461
elog(NOTICE,
460462
"RuntimeAppend, RuntimeMergeAppend and PartitionFilter nodes "

‎src/include/compat/pg_compat.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@
1919
#include"nodes/pg_list.h"
2020
#include"optimizer/cost.h"
2121
#include"optimizer/paths.h"
22+
#include"utils/memutils.h"
23+
24+
/* Define ALLOCSET_DEFAULT_SIZES for our precious MemoryContexts */
25+
#ifPG_VERSION_NUM<90600
26+
#defineALLOCSET_DEFAULT_SIZES \
27+
ALLOCSET_DEFAULT_MINSIZE, ALLOCSET_DEFAULT_INITSIZE, ALLOCSET_DEFAULT_MAXSIZE
28+
#endif
2229

2330

2431
/*

‎src/include/init.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,21 +67,21 @@ static inline const char *
6767
simpify_mcxt_name(MemoryContextmcxt)
6868
{
6969
staticconstchar*top_mcxt="maintenance",
70-
*bound_mcxt="partitionpruning cache",
70+
*rel_mcxt="partitiondispatch cache",
7171
*parent_mcxt="partition parents cache",
72-
*constr_mcxt="partition bounds cache";
72+
*bound_mcxt="partition bounds cache";
7373

7474
if (mcxt==TopPathmanContext)
7575
returntop_mcxt;
7676

7777
elseif (mcxt==PathmanRelationCacheContext)
78-
returnbound_mcxt;
78+
returnrel_mcxt;
7979

8080
elseif (mcxt==PathmanParentCacheContext)
8181
returnparent_mcxt;
8282

8383
elseif (mcxt==PathmanBoundCacheContext)
84-
returnconstr_mcxt;
84+
returnbound_mcxt;
8585

8686
elseelog(ERROR,"error in function "CppAsString(simpify_mcxt_name));
8787
}

‎src/include/relation_info.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ cmp_bounds(FmgrInfo *cmp_func, const Bound *b1, const Bound *b2)
9898
}
9999

100100

101+
101102
/*
102103
* Partitioning type.
103104
*/
@@ -192,6 +193,7 @@ typedef enum
192193
}PartParentSearch;
193194

194195

196+
195197
/*
196198
* PartRelationInfo field access macros.
197199
*/
@@ -324,4 +326,11 @@ FreeRangesArray(PartRelationInfo *prel)
324326
}
325327
}
326328

329+
330+
/* For pg_pathman.enable_bounds_cache GUC */
331+
externboolpg_pathman_enable_bounds_cache;
332+
333+
voidinit_relation_info_static_data(void);
334+
335+
327336
#endif/* RELATION_INFO_H */

‎src/init.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
* ------------------------------------------------------------------------
1212
*/
1313

14+
#include"compat/pg_compat.h"
15+
1416
#include"hooks.h"
1517
#include"init.h"
1618
#include"pathman.h"
@@ -38,12 +40,6 @@
3840
#include"utils/typcache.h"
3941

4042

41-
/* Define ALLOCSET_DEFAULT_SIZES for our precious MemoryContexts */
42-
#ifPG_VERSION_NUM<90600
43-
#defineALLOCSET_DEFAULT_SIZES \
44-
ALLOCSET_DEFAULT_MINSIZE, ALLOCSET_DEFAULT_INITSIZE, ALLOCSET_DEFAULT_MAXSIZE
45-
#endif
46-
4743
/* Initial size of 'partitioned_rels' table */
4844
#definePART_RELS_SIZE10
4945
#defineCHILD_FACTOR500

‎src/pg_pathman.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ _PG_init(void)
160160

161161
/* Initialize static data for all subsystems */
162162
init_main_pathman_toggles();
163+
init_relation_info_static_data();
163164
init_runtimeappend_static_data();
164165
init_runtime_merge_append_static_data();
165166
init_partition_filter_static_data();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp