@@ -717,11 +717,16 @@ equality_ops_are_compatible(Oid opno1, Oid opno2)
717
717
{
718
718
HeapTuple op_tuple = & catlist -> members [i ]-> tuple ;
719
719
Form_pg_amop op_form = (Form_pg_amop ) GETSTRUCT (op_tuple );
720
- IndexAmRoutine * amroutine = GetIndexAmRoutineByAmId (op_form -> amopmethod , false);
721
720
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 ))
723
726
{
724
- if (op_in_opfamily (opno2 , op_form -> amopfamily ))
727
+ IndexAmRoutine * amroutine = GetIndexAmRoutineByAmId (op_form -> amopmethod , false);
728
+
729
+ if (amroutine -> amconsistentequality )
725
730
{
726
731
result = true;
727
732
break ;
@@ -768,11 +773,16 @@ comparison_ops_are_compatible(Oid opno1, Oid opno2)
768
773
{
769
774
HeapTuple op_tuple = & catlist -> members [i ]-> tuple ;
770
775
Form_pg_amop op_form = (Form_pg_amop ) GETSTRUCT (op_tuple );
771
- IndexAmRoutine * amroutine = GetIndexAmRoutineByAmId (op_form -> amopmethod , false);
772
776
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 ))
774
782
{
775
- if (op_in_opfamily (opno2 , op_form -> amopfamily ))
783
+ IndexAmRoutine * amroutine = GetIndexAmRoutineByAmId (op_form -> amopmethod , false);
784
+
785
+ if (amroutine -> amcanorder && amroutine -> amconsistentordering )
776
786
{
777
787
result = true;
778
788
break ;
0 commit comments