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

Commitcce442d

Browse files
committed
Dept. of second thoughts: clause_selectivity shouldn't try to cache its
result for jointypes associated with IN processing.
1 parent9091e8d commitcce442d

File tree

1 file changed

+29
-8
lines changed

1 file changed

+29
-8
lines changed

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

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/optimizer/path/clausesel.c,v 1.63 2004/01/04 03:51:52 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/optimizer/path/clausesel.c,v 1.64 2004/01/05 16:44:40 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -417,17 +417,38 @@ clause_selectivity(Query *root,
417417
* If possible, cache the result of the selectivity calculation for
418418
* the clause. We can cache if varRelid is zero or the clause
419419
* contains only vars of that relid --- otherwise varRelid will affect
420-
* the result, so mustn't cache. We ignore the possibility that
421-
* jointype will affect the result, which should be okay because outer
422-
* join clauses will always be examined with the same jointype value.
420+
* the result, so mustn't cache. We also have to be careful about
421+
* the jointype. It's OK to cache when jointype is JOIN_INNER or
422+
* one of the outer join types (any given outer-join clause should
423+
* always be examined with the same jointype, so result won't change).
424+
* It's not OK to cache when jointype is one of the special types
425+
* associated with IN processing, because the same clause may be
426+
* examined with different jointypes and the result should vary.
423427
*/
424428
if (varRelid==0||
425429
bms_is_subset_singleton(rinfo->clause_relids,varRelid))
426430
{
427-
/* Cacheable --- do we already have the result? */
428-
if (rinfo->this_selec >=0)
429-
returnrinfo->this_selec;
430-
cacheable= true;
431+
switch (jointype)
432+
{
433+
caseJOIN_INNER:
434+
caseJOIN_LEFT:
435+
caseJOIN_FULL:
436+
caseJOIN_RIGHT:
437+
/* Cacheable --- do we already have the result? */
438+
if (rinfo->this_selec >=0)
439+
returnrinfo->this_selec;
440+
cacheable= true;
441+
break;
442+
443+
caseJOIN_UNION:
444+
/* unimplemented anyway... */
445+
caseJOIN_IN:
446+
caseJOIN_REVERSE_IN:
447+
caseJOIN_UNIQUE_OUTER:
448+
caseJOIN_UNIQUE_INNER:
449+
/* unsafe to cache */
450+
break;
451+
}
431452
}
432453

433454
/* Proceed with examination of contained clause */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp