aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>1999-02-01 04:20:50 +0000
committerTom Lane <tgl@sss.pgh.pa.us>1999-02-01 04:20:50 +0000
commit757f40345141bf31ea380128cbf2fd2dde4a2798 (patch)
treeaa3986c65c861f50cb5f58f3682224e4c708afdb /src
parent6ca2bf65346f0c54ac3347fbcb003cc2f8242fc4 (diff)
downloadpostgresql-757f40345141bf31ea380128cbf2fd2dde4a2798.tar.gz
postgresql-757f40345141bf31ea380128cbf2fd2dde4a2798.zip
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 ...
Diffstat (limited to 'src')
-rw-r--r--src/backend/optimizer/util/keys.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/backend/optimizer/util/keys.c b/src/backend/optimizer/util/keys.c
index 3e2372339d3..685e01cbafd 100644
--- a/src/backend/optimizer/util/keys.c
+++ b/src/backend/optimizer/util/keys.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/util/Attic/keys.c,v 1.9 1998/09/01 04:30:07 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/util/Attic/keys.c,v 1.10 1999/02/01 04:20:50 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -120,16 +120,20 @@ extract_subkey(JoinKey *jk, int which_subkey)
bool
samekeys(List *keys1, List *keys2)
{
- bool allmember = true;
List *key1,
*key2;
for (key1 = keys1, key2 = keys2; key1 != NIL && key2 != NIL;
key1 = lnext(key1), key2 = lnext(key2))
if (!member(lfirst(key1), lfirst(key2)))
- allmember = false;
-
- if ((length(keys2) >= length(keys1)) && allmember)
+ return false;
+
+ /* Now the result should be true if list keys2 has at least as many
+ * entries as keys1, ie, we did not fall off the end of keys2 first.
+ * If key1 is now NIL then we hit the end of keys1 before or at the
+ * same time as the end of keys2.
+ */
+ if (key1 == NIL)
return true;
else
return false;