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

Commit7f24c02

Browse files
committed
Improve possible performance regression
Commitce62f2f introduced calls to GetIndexAmRoutineByAmId() inlsyscache.c functions. This call is a bit more expensive than asimple syscache lookup. So rearrange the nesting so that we call thatone last and do the cheaper checks first.Reported-by: Tom Lane <tgl@sss.pgh.pa.us>Discussion:https://www.postgresql.org/message-id/flat/E1tngY6-0000UL-2n%40gemulon.postgresql.org
1 parentaf4002b commit7f24c02

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

‎src/backend/utils/cache/lsyscache.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -717,11 +717,16 @@ equality_ops_are_compatible(Oid opno1, Oid opno2)
717717
{
718718
HeapTupleop_tuple=&catlist->members[i]->tuple;
719719
Form_pg_amopop_form= (Form_pg_amop)GETSTRUCT(op_tuple);
720-
IndexAmRoutine*amroutine=GetIndexAmRoutineByAmId(op_form->amopmethod, false);
721720

722-
if (amroutine->amconsistentequality)
721+
/*
722+
* op_in_opfamily() is cheaper than GetIndexAmRoutineByAmId(), so
723+
* check it first
724+
*/
725+
if (op_in_opfamily(opno2,op_form->amopfamily))
723726
{
724-
if (op_in_opfamily(opno2,op_form->amopfamily))
727+
IndexAmRoutine*amroutine=GetIndexAmRoutineByAmId(op_form->amopmethod, false);
728+
729+
if (amroutine->amconsistentequality)
725730
{
726731
result= true;
727732
break;
@@ -768,11 +773,16 @@ comparison_ops_are_compatible(Oid opno1, Oid opno2)
768773
{
769774
HeapTupleop_tuple=&catlist->members[i]->tuple;
770775
Form_pg_amopop_form= (Form_pg_amop)GETSTRUCT(op_tuple);
771-
IndexAmRoutine*amroutine=GetIndexAmRoutineByAmId(op_form->amopmethod, false);
772776

773-
if (amroutine->amcanorder&&amroutine->amconsistentordering)
777+
/*
778+
* op_in_opfamily() is cheaper than GetIndexAmRoutineByAmId(), so
779+
* check it first
780+
*/
781+
if (op_in_opfamily(opno2,op_form->amopfamily))
774782
{
775-
if (op_in_opfamily(opno2,op_form->amopfamily))
783+
IndexAmRoutine*amroutine=GetIndexAmRoutineByAmId(op_form->amopmethod, false);
784+
785+
if (amroutine->amcanorder&&amroutine->amconsistentordering)
776786
{
777787
result= true;
778788
break;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp