Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 757f403

Browse files
committed
Tighten coding in samekeys(). Pretty braindead change,
but it saves almost 10% of the runtime in Charles Hornberger's optimizer example, so what the heck ...
1 parent 6ca2bf6 commit 757f403

File tree

1 file changed

+9
-5
lines changed
  • src/backend/optimizer/util

1 file changed

+9
-5
lines changed

src/backend/optimizer/util/keys.c

+9-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/Attic/keys.c,v 1.9 1998/09/01 04:30:07 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/Attic/keys.c,v 1.10 1999/02/01 04:20:50 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -120,16 +120,20 @@ extract_subkey(JoinKey *jk, int which_subkey)
120120
bool
121121
samekeys(List *keys1, List *keys2)
122122
{
123-
bool allmember = true;
124123
List *key1,
125124
*key2;
126125

127126
for (key1 = keys1, key2 = keys2; key1 != NIL && key2 != NIL;
128127
key1 = lnext(key1), key2 = lnext(key2))
129128
if (!member(lfirst(key1), lfirst(key2)))
130-
allmember = false;
131-
132-
if ((length(keys2) >= length(keys1)) && allmember)
129+
return false;
130+
131+
/* Now the result should be true if list keys2 has at least as many
132+
* entries as keys1, ie, we did not fall off the end of keys2 first.
133+
* If key1 is now NIL then we hit the end of keys1 before or at the
134+
* same time as the end of keys2.
135+
*/
136+
if (key1 == NIL)
133137
return true;
134138
else
135139
return false;

0 commit comments

Comments
 (0)