mirror of
https://github.com/postgres/postgres.git
synced 2025-07-31 22:04:40 +03:00
Improve possible performance regression
Commit ce62f2f2a0
introduced calls to GetIndexAmRoutineByAmId() in
lsyscache.c functions. This call is a bit more expensive than a
simple syscache lookup. So rearrange the nesting so that we call that
one 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
This commit is contained in:
18
src/backend/utils/cache/lsyscache.c
vendored
18
src/backend/utils/cache/lsyscache.c
vendored
@ -717,11 +717,16 @@ equality_ops_are_compatible(Oid opno1, Oid opno2)
|
||||
{
|
||||
HeapTuple op_tuple = &catlist->members[i]->tuple;
|
||||
Form_pg_amop op_form = (Form_pg_amop) GETSTRUCT(op_tuple);
|
||||
|
||||
/*
|
||||
* op_in_opfamily() is cheaper than GetIndexAmRoutineByAmId(), so
|
||||
* check it first
|
||||
*/
|
||||
if (op_in_opfamily(opno2, op_form->amopfamily))
|
||||
{
|
||||
IndexAmRoutine *amroutine = GetIndexAmRoutineByAmId(op_form->amopmethod, false);
|
||||
|
||||
if (amroutine->amconsistentequality)
|
||||
{
|
||||
if (op_in_opfamily(opno2, op_form->amopfamily))
|
||||
{
|
||||
result = true;
|
||||
break;
|
||||
@ -768,11 +773,16 @@ comparison_ops_are_compatible(Oid opno1, Oid opno2)
|
||||
{
|
||||
HeapTuple op_tuple = &catlist->members[i]->tuple;
|
||||
Form_pg_amop op_form = (Form_pg_amop) GETSTRUCT(op_tuple);
|
||||
|
||||
/*
|
||||
* op_in_opfamily() is cheaper than GetIndexAmRoutineByAmId(), so
|
||||
* check it first
|
||||
*/
|
||||
if (op_in_opfamily(opno2, op_form->amopfamily))
|
||||
{
|
||||
IndexAmRoutine *amroutine = GetIndexAmRoutineByAmId(op_form->amopmethod, false);
|
||||
|
||||
if (amroutine->amcanorder && amroutine->amconsistentordering)
|
||||
{
|
||||
if (op_in_opfamily(opno2, op_form->amopfamily))
|
||||
{
|
||||
result = true;
|
||||
break;
|
||||
|
Reference in New Issue
Block a user