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

Commit20fbd32

Browse files
committed
add 'entries' to 'pathman_cache_stats' view
1 parent0c3233c commit20fbd32

File tree

3 files changed

+24
-9
lines changed

3 files changed

+24
-9
lines changed

‎init.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,8 @@ CREATE OR REPLACE FUNCTION @extschema@.show_cache_stats()
274274
RETURNS TABLE (
275275
contextTEXT,
276276
sizeINT8,
277-
usedINT8)
277+
usedINT8,
278+
entriesINT8)
278279
AS'pg_pathman','show_cache_stats_internal'
279280
LANGUAGE C STRICT;
280281

‎src/include/pathman.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,11 @@
7979
* Definitions for the "pathman_cache_stats" view.
8080
*/
8181
#definePATHMAN_CACHE_STATS"pathman_cache_stats"
82-
#defineNatts_pathman_cache_stats3
82+
#defineNatts_pathman_cache_stats4
8383
#defineAnum_pathman_cs_context1/* name of memory context */
8484
#defineAnum_pathman_cs_size2/* size of memory context */
8585
#defineAnum_pathman_cs_used3/* used space */
86+
#defineAnum_pathman_cs_entries4/* number of cache entries */
8687

8788

8889
/*

‎src/pl_funcs.c

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ typedef struct
8989
typedefstruct
9090
{
9191
MemoryContextpathman_contexts[PATHMAN_MCXT_COUNT];
92-
intcurrent_context;
92+
HTAB*pathman_htables[PATHMAN_MCXT_COUNT];
93+
intcurrent_item;
9394
}show_cache_stats_cxt;
9495

9596

@@ -299,7 +300,12 @@ show_cache_stats_internal(PG_FUNCTION_ARGS)
299300
usercxt->pathman_contexts[2]=PathmanParentCacheContext;
300301
usercxt->pathman_contexts[3]=PathmanCostraintCacheContext;
301302

302-
usercxt->current_context=0;
303+
usercxt->pathman_htables[0]=NULL;/* no HTAB for this entry */
304+
usercxt->pathman_htables[1]=partitioned_rels;
305+
usercxt->pathman_htables[2]=parent_cache;
306+
usercxt->pathman_htables[3]=constraint_cache;
307+
308+
usercxt->current_item=0;
303309

304310
/* Create tuple descriptor */
305311
tupdesc=CreateTemplateTupleDesc(Natts_pathman_cache_stats, false);
@@ -310,6 +316,8 @@ show_cache_stats_internal(PG_FUNCTION_ARGS)
310316
"size",INT8OID,-1,0);
311317
TupleDescInitEntry(tupdesc,Anum_pathman_cs_used,
312318
"used",INT8OID,-1,0);
319+
TupleDescInitEntry(tupdesc,Anum_pathman_cs_entries,
320+
"entries",INT8OID,-1,0);
313321

314322
funccxt->tuple_desc=BlessTupleDesc(tupdesc);
315323
funccxt->user_fctx= (void*)usercxt;
@@ -320,8 +328,9 @@ show_cache_stats_internal(PG_FUNCTION_ARGS)
320328
funccxt=SRF_PERCALL_SETUP();
321329
usercxt= (show_cache_stats_cxt*)funccxt->user_fctx;
322330

323-
if (usercxt->current_context<lengthof(usercxt->pathman_contexts))
331+
if (usercxt->current_item<lengthof(usercxt->pathman_contexts))
324332
{
333+
HTAB*current_htab;
325334
MemoryContextcurrent_mcxt;
326335
MemoryContextCountersmcxt_stats;
327336
HeapTuplehtup;
@@ -331,8 +340,9 @@ show_cache_stats_internal(PG_FUNCTION_ARGS)
331340
/* Prepare context counters */
332341
memset(&mcxt_stats,0,sizeof(mcxt_stats));
333342

334-
/* Select current memory context */
335-
current_mcxt=usercxt->pathman_contexts[usercxt->current_context];
343+
/* Select current memory context and hash table (cache) */
344+
current_mcxt=usercxt->pathman_contexts[usercxt->current_item];
345+
current_htab=usercxt->pathman_htables[usercxt->current_item];
336346

337347
/* NOTE: we do not consider child contexts if it's TopPathmanContext */
338348
McxtStatsInternal(current_mcxt,0,
@@ -348,8 +358,11 @@ show_cache_stats_internal(PG_FUNCTION_ARGS)
348358
values[Anum_pathman_cs_used-1]=
349359
Int64GetDatum(mcxt_stats.totalspace-mcxt_stats.freespace);
350360

351-
/* Switch to next context */
352-
usercxt->current_context++;
361+
values[Anum_pathman_cs_entries-1]=
362+
Int64GetDatum(current_htab ?hash_get_num_entries(current_htab) :0);
363+
364+
/* Switch to next item */
365+
usercxt->current_item++;
353366

354367
/* Form output tuple */
355368
htup=heap_form_tuple(funccxt->tuple_desc,values,isnull);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp