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

Commit4e0b63b

Browse files
committed
Teach pgstat_vacuum_stat to not bother scanning pg_proc in the common case
where no function stats entries exist. Partial response to Pavel'sobservation that small VACUUM operations are noticeably slower in CVS HEADthan 8.3.
1 parentbd33aca commit4e0b63b

File tree

1 file changed

+38
-33
lines changed

1 file changed

+38
-33
lines changed

‎src/backend/postmaster/pgstat.c

Lines changed: 38 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
*Copyright (c) 2001-2008, PostgreSQL Global Development Group
1515
*
16-
*$PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.184 2008/11/04 11:04:06 petere Exp $
16+
*$PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.185 2008/12/08 15:44:54 tgl Exp $
1717
* ----------
1818
*/
1919
#include"postgres.h"
@@ -967,55 +967,60 @@ pgstat_vacuum_stat(void)
967967
hash_destroy(htab);
968968

969969
/*
970-
* Now repeat the above steps for functions.
970+
* Now repeat the above steps for functions. However, we needn't bother
971+
* in the common case where no function stats are being collected.
971972
*/
972-
htab=pgstat_collect_oids(ProcedureRelationId);
973+
if (dbentry->functions!=NULL&&
974+
hash_get_num_entries(dbentry->functions)>0)
975+
{
976+
htab=pgstat_collect_oids(ProcedureRelationId);
973977

974-
pgstat_setheader(&f_msg.m_hdr,PGSTAT_MTYPE_FUNCPURGE);
975-
f_msg.m_databaseid=MyDatabaseId;
976-
f_msg.m_nentries=0;
978+
pgstat_setheader(&f_msg.m_hdr,PGSTAT_MTYPE_FUNCPURGE);
979+
f_msg.m_databaseid=MyDatabaseId;
980+
f_msg.m_nentries=0;
977981

978-
hash_seq_init(&hstat,dbentry->functions);
979-
while ((funcentry= (PgStat_StatFuncEntry*)hash_seq_search(&hstat))!=NULL)
980-
{
981-
Oidfuncid=funcentry->functionid;
982+
hash_seq_init(&hstat,dbentry->functions);
983+
while ((funcentry= (PgStat_StatFuncEntry*)hash_seq_search(&hstat))!=NULL)
984+
{
985+
Oidfuncid=funcentry->functionid;
982986

983-
CHECK_FOR_INTERRUPTS();
987+
CHECK_FOR_INTERRUPTS();
984988

985-
if (hash_search(htab, (void*)&funcid,HASH_FIND,NULL)!=NULL)
986-
continue;
989+
if (hash_search(htab, (void*)&funcid,HASH_FIND,NULL)!=NULL)
990+
continue;
987991

988-
/*
989-
* Not there, so add this function's Oid to the message
990-
*/
991-
f_msg.m_functionid[f_msg.m_nentries++]=funcid;
992+
/*
993+
* Not there, so add this function's Oid to the message
994+
*/
995+
f_msg.m_functionid[f_msg.m_nentries++]=funcid;
996+
997+
/*
998+
* If the message is full, send it out and reinitialize to empty
999+
*/
1000+
if (f_msg.m_nentries >=PGSTAT_NUM_FUNCPURGE)
1001+
{
1002+
len= offsetof(PgStat_MsgFuncpurge,m_functionid[0])
1003+
+f_msg.m_nentries*sizeof(Oid);
1004+
1005+
pgstat_send(&f_msg,len);
1006+
1007+
f_msg.m_nentries=0;
1008+
}
1009+
}
9921010

9931011
/*
994-
*If themessage is full, send it out and reinitialize to empty
1012+
*Send therest
9951013
*/
996-
if (f_msg.m_nentries >=PGSTAT_NUM_FUNCPURGE)
1014+
if (f_msg.m_nentries>0)
9971015
{
9981016
len= offsetof(PgStat_MsgFuncpurge,m_functionid[0])
9991017
+f_msg.m_nentries*sizeof(Oid);
10001018

10011019
pgstat_send(&f_msg,len);
1002-
1003-
f_msg.m_nentries=0;
10041020
}
1005-
}
10061021

1007-
/*
1008-
* Send the rest
1009-
*/
1010-
if (f_msg.m_nentries>0)
1011-
{
1012-
len= offsetof(PgStat_MsgFuncpurge,m_functionid[0])
1013-
+f_msg.m_nentries*sizeof(Oid);
1014-
1015-
pgstat_send(&f_msg,len);
1022+
hash_destroy(htab);
10161023
}
1017-
1018-
hash_destroy(htab);
10191024
}
10201025

10211026

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp