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

Commit21eb6ae

Browse files
committed
Shave a few cycles in compare_pathkeys() by checking for pointer-identical
input lists before we grovel through the lists. This doesn't save much,but testing shows that the case of both inputs NIL is common enough thatit saves something. And this is used enough to be a hotspot.
1 parent640796f commit21eb6ae

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

‎src/backend/optimizer/path/pathkeys.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Portions Copyright (c) 1994, Regents of the University of California
1212
*
1313
* IDENTIFICATION
14-
* $PostgreSQL: pgsql/src/backend/optimizer/path/pathkeys.c,v 1.96 2009/01/01 17:23:44 momjian Exp $
14+
* $PostgreSQL: pgsql/src/backend/optimizer/path/pathkeys.c,v 1.97 2009/02/28 03:51:05 tgl Exp $
1515
*
1616
*-------------------------------------------------------------------------
1717
*/
@@ -332,6 +332,14 @@ compare_pathkeys(List *keys1, List *keys2)
332332
ListCell*key1,
333333
*key2;
334334

335+
/*
336+
* Fall out quickly if we are passed two identical lists. This mostly
337+
* catches the case where both are NIL, but that's common enough to
338+
* warrant the test.
339+
*/
340+
if (keys1==keys2)
341+
returnPATHKEYS_EQUAL;
342+
335343
forboth(key1,keys1,key2,keys2)
336344
{
337345
PathKey*pathkey1= (PathKey*)lfirst(key1);
@@ -354,11 +362,11 @@ compare_pathkeys(List *keys1, List *keys2)
354362
* If we reached the end of only one list, the other is longer and
355363
* therefore not a subset.
356364
*/
357-
if (key1==NULL&&key2==NULL)
358-
returnPATHKEYS_EQUAL;
359365
if (key1!=NULL)
360366
returnPATHKEYS_BETTER1;/* key1 is longer */
361-
returnPATHKEYS_BETTER2;/* key2 is longer */
367+
if (key2!=NULL)
368+
returnPATHKEYS_BETTER2;/* key2 is longer */
369+
returnPATHKEYS_EQUAL;
362370
}
363371

364372
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp