diff options
Diffstat (limited to 'src/backend/optimizer/path/clausesel.c')
-rw-r--r-- | src/backend/optimizer/path/clausesel.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/src/backend/optimizer/path/clausesel.c b/src/backend/optimizer/path/clausesel.c index e736c6e309e..996c98cc469 100644 --- a/src/backend/optimizer/path/clausesel.c +++ b/src/backend/optimizer/path/clausesel.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/path/clausesel.c,v 1.67 2004/05/30 23:40:28 neilc Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/path/clausesel.c,v 1.68 2004/06/11 01:08:49 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -487,16 +487,27 @@ clause_selectivity(Query *root, } } } - else if (IsA(clause, Param)) - { - /* XXX any way to do better? */ - s1 = 1.0; - } else if (IsA(clause, Const)) { /* bool constant is pretty easy... */ s1 = ((bool) ((Const *) clause)->constvalue) ? 1.0 : 0.0; } + else if (IsA(clause, Param)) + { + /* see if we can replace the Param */ + Node *subst = estimate_expression_value(clause); + + if (IsA(subst, Const)) + { + /* bool constant is pretty easy... */ + s1 = ((bool) ((Const *) subst)->constvalue) ? 1.0 : 0.0; + } + else + { + /* XXX any way to do better? */ + s1 = (Selectivity) 0.5; + } + } else if (not_clause(clause)) { /* inverse of the selectivity of the underlying clause */ |