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

Commit29a43f3

Browse files
committed
Tweak grammar to use FastAppend rather than lappend when constructing
expr_lists. This appears to be the only remaining O(N^2) bottleneckin processing many-way 'x IN (a,b,c,...)' conditions.
1 parent92ee252 commit29a43f3

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

‎src/backend/parser/gram.y

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
*
1313
* IDENTIFICATION
14-
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.429 2003/08/17 19:58:05 tgl Exp $
14+
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.430 2003/08/22 20:34:33 tgl Exp $
1515
*
1616
* HISTORY
1717
* AUTHORDATEMAJOR EVENT
@@ -108,6 +108,7 @@ static void doNegateFloat(Value *v);
108108
DropBehaviordbehavior;
109109
OnCommitActiononcommit;
110110
List*list;
111+
FastListfastlist;
111112
Node*node;
112113
Value*value;
113114
ColumnRef*columnref;
@@ -6719,8 +6720,18 @@ opt_indirection:
67196720
{ $$ = NIL; }
67206721
;
67216722

6722-
expr_list:a_expr{ $$ =makeList1($1); }
6723-
| expr_list',' a_expr{ $$ =lappend($1, $3); }
6723+
expr_list:a_expr
6724+
{
6725+
FastList *dst = (FastList *) &$$;
6726+
makeFastList1(dst, $1);
6727+
}
6728+
| expr_list',' a_expr
6729+
{
6730+
FastList *dst = (FastList *) &$$;
6731+
FastList *src = (FastList *) &$1;
6732+
*dst = *src;
6733+
FastAppend(dst, $3);
6734+
}
67246735
;
67256736

67266737
extract_list:

‎src/include/nodes/pg_list.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: pg_list.h,v 1.40 2003/08/08 21:42:48 momjian Exp $
10+
* $Id: pg_list.h,v 1.41 2003/08/22 20:34:33 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -132,6 +132,9 @@ typedef struct List
132132
* FastList is an optimization for building large lists. The conventional
133133
* way to build a list is repeated lappend() operations, but that is O(N^2)
134134
* in the number of list items, which gets tedious for large lists.
135+
*
136+
* Note: there are some hacks in gram.y that rely on the head pointer (the
137+
* value-as-list) being the first field.
135138
*/
136139
typedefstructFastList
137140
{
@@ -144,6 +147,9 @@ typedef struct FastList
144147
( (fl)->head = (l), (fl)->tail = llastnode((fl)->head) )
145148
#defineFastListValue(fl)( (fl)->head )
146149

150+
#definemakeFastList1(fl,x1) \
151+
( (fl)->head = (fl)->tail = makeList1(x1) )
152+
147153

148154
/*
149155
* function prototypes in nodes/list.c

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp