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

Commit34ecb9d

Browse files
committed
Optimizer cleanups.
1 parentc873fcd commit34ecb9d

File tree

2 files changed

+49
-45
lines changed

2 files changed

+49
-45
lines changed

‎src/backend/optimizer/util/ordering.c

Lines changed: 6 additions & 5 deletions
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/ordering.c,v 1.13 1999/02/1117:00:48 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/Attic/ordering.c,v 1.14 1999/02/1121:05:28 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -18,7 +18,8 @@
1818
#include"optimizer/internal.h"
1919
#include"optimizer/ordering.h"
2020

21-
staticboolequal_sortops_order(Oid*ordering1,Oid*ordering2,int*better_sort);
21+
staticboolsortops_order_match(Oid*ordering1,Oid*ordering2,
22+
int*better_sort);
2223

2324
/*
2425
* equal-path-ordering--
@@ -56,7 +57,7 @@ pathorder_match(PathOrder *path_ordering1,
5657
elseif (path_ordering1->ordtype==SORTOP_ORDER&&
5758
path_ordering2->ordtype==SORTOP_ORDER)
5859
{
59-
returnequal_sortops_order(path_ordering1->ord.sortop,
60+
returnsortops_order_match(path_ordering1->ord.sortop,
6061
path_ordering2->ord.sortop,
6162
better_sort);
6263
}
@@ -127,7 +128,7 @@ equal_merge_ordering(MergeOrder *merge_ordering1,
127128
* Returns true iff the sort operators are in the same order.
128129
*/
129130
staticbool
130-
equal_sortops_order(Oid*ordering1,Oid*ordering2,int*better_sort)
131+
sortops_order_match(Oid*ordering1,Oid*ordering2,int*better_sort)
131132
{
132133
inti=0;
133134

@@ -160,7 +161,7 @@ equal_sortops_order(Oid *ordering1, Oid *ordering2, int *better_sort)
160161
*better_sort=1;
161162
return true;
162163
}
163-
164+
164165
if (ordering1[i]==0&&ordering2[i]!=0)
165166
{
166167
*better_sort=2;

‎src/backend/optimizer/util/pathnode.c

Lines changed: 43 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/pathnode.c,v 1.30 1999/02/1117:21:51 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/pathnode.c,v 1.31 1999/02/11 21:05:28 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -29,7 +29,7 @@
2929

3030
#include"parser/parsetree.h"/* for getrelid() */
3131

32-
staticPath*better_path(Path*new_path,List*unique_paths,bool*isNew);
32+
staticPath*better_path(Path*new_path,List*unique_paths,bool*is_new);
3333

3434

3535
/*****************************************************************************
@@ -173,11 +173,14 @@ better_path(Path *new_path, List *unique_paths, bool *is_new)
173173
printf("newpath\n");
174174
pprint(new_path->pathkeys);
175175
if (path->pathkeys&&new_path->pathkeys&&
176-
length(lfirst(path->pathkeys)) >=2&&
177-
length(lfirst(path->pathkeys))<length(lfirst(new_path->pathkeys)))
176+
length(lfirst(path->pathkeys)) >=2/* &&
177+
length(lfirst(path->pathkeys)) <
178+
length(lfirst(new_path->pathkeys))*/)
178179
sleep(0);/* set breakpoint here */
179180
}
180-
if (!pathorder_match(new_path->pathorder,path->pathorder,&better_sort))
181+
if (!pathorder_match(new_path->pathorder,path->pathorder,
182+
&better_sort)||
183+
better_sort!=0)
181184
{
182185
printf("oldord\n");
183186
pprint(path->pathorder);
@@ -186,43 +189,43 @@ better_path(Path *new_path, List *unique_paths, bool *is_new)
186189
}
187190
#endif
188191

189-
if (pathkeys_match(new_path->pathkeys,path->pathkeys,&better_key))
192+
if (pathkeys_match(new_path->pathkeys,path->pathkeys,
193+
&better_key)&&
194+
pathorder_match(new_path->pathorder,path->pathorder,
195+
&better_sort))
190196
{
191-
if (pathorder_match(new_path->pathorder,path->pathorder,&better_sort))
197+
/*
198+
* Replace pathkeys that match exactly, (1,2), (1,2).
199+
* Replace pathkeys (1,2) with (1,2,3) if the latter is not
200+
* more expensive and replace unordered path with ordered
201+
* path if it is not more expensive. Favor sorted keys
202+
* over unsorted keys in the same way.
203+
*/
204+
/* same keys, and new is cheaper, use it */
205+
if ((better_key==0&&better_sort==0&&
206+
new_path->path_cost<path->path_cost)||
207+
208+
/* new is better, and cheaper, use it */
209+
(((better_key==1&&better_sort!=2)||
210+
(better_key!=2&&better_sort==1))&&
211+
new_path->path_cost <=path->path_cost))
192212
{
193-
/*
194-
* Replace pathkeys that match exactly, (1,2), (1,2).
195-
* Replace pathkeys (1,2) with (1,2,3) if the latter is not
196-
* more expensive and replace unordered path with ordered
197-
* path if it is not more expensive. Favor sorted keys
198-
* over unsorted keys in the same way.
199-
*/
200-
/* same keys, and new is cheaper, use it */
201-
if ((better_key==0&&better_sort==0&&
202-
new_path->path_cost<path->path_cost)||
203-
204-
/* new is better, and cheaper, use it */
205-
(((better_key==1&&better_sort!=2)||
206-
(better_key!=2&&better_sort==1))&&
207-
new_path->path_cost <=path->path_cost))
208-
{
209-
*is_new= false;
210-
returnnew_path;
211-
}
212-
213-
/* same keys, new is more expensive, stop */
214-
elseif
215-
((better_key==0&&better_sort==0&&
216-
new_path->path_cost >=path->path_cost)||
217-
218-
/* old is better, and less expensive, stop */
219-
(((better_key==2&&better_sort!=1)||
220-
(better_key!=1&&better_sort==2))&&
221-
new_path->path_cost >=path->path_cost))
222-
{
223-
*is_new= false;
224-
returnNULL;
225-
}
213+
*is_new= false;
214+
returnnew_path;
215+
}
216+
217+
/* same keys, new is more expensive, stop */
218+
elseif
219+
((better_key==0&&better_sort==0&&
220+
new_path->path_cost >=path->path_cost)||
221+
222+
/* old is better, and less expensive, stop */
223+
(((better_key==2&&better_sort!=1)||
224+
(better_key!=1&&better_sort==2))&&
225+
new_path->path_cost >=path->path_cost))
226+
{
227+
*is_new= false;
228+
returnNULL;
226229
}
227230
}
228231
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp