* get_loop_count * Choose the loop count estimate to use for costing a parameterized path * with the given set of outer relids. * * Since we produce parameterized paths before we've begun to generate join * relations, it's impossible to predict exactly how many times a parameterized * path will be iterated; we don't know the size of the relation that will be * on the outside of the nestlo
| 1957 | * calls create_index_paths(). |
| 1958 | */ |
| 1959 | static double |
| 1960 | get_loop_count(PlannerInfo *root, Index cur_relid, Relids outer_relids) |
| 1961 | { |
| 1962 | double result; |
| 1963 | int outer_relid; |
| 1964 | |
| 1965 | /* For a non-parameterized path, just return 1.0 quickly */ |
| 1966 | if (outer_relids == NULL) |
| 1967 | return 1.0; |
| 1968 | |
| 1969 | result = 0.0; |
| 1970 | outer_relid = -1; |
| 1971 | while ((outer_relid = bms_next_member(outer_relids, outer_relid)) >= 0) |
| 1972 | { |
| 1973 | RelOptInfo *outer_rel; |
| 1974 | double rowcount; |
| 1975 | |
| 1976 | /* Paranoia: ignore bogus relid indexes */ |
| 1977 | if (outer_relid >= root->simple_rel_array_size) |
| 1978 | continue; |
| 1979 | outer_rel = root->simple_rel_array[outer_relid]; |
| 1980 | if (outer_rel == NULL) |
| 1981 | continue; |
| 1982 | Assert(outer_rel->relid == outer_relid); /* sanity check on array */ |
| 1983 | |
| 1984 | /* Other relation could be proven empty, if so ignore */ |
| 1985 | if (IS_DUMMY_REL(outer_rel)) |
| 1986 | continue; |
| 1987 | |
| 1988 | /* Otherwise, rel's rows estimate should be valid by now */ |
| 1989 | Assert(outer_rel->rows > 0); |
| 1990 | |
| 1991 | /* Check to see if rel is on the inside of any semijoins */ |
| 1992 | rowcount = adjust_rowcount_for_semijoins(root, |
| 1993 | cur_relid, |
| 1994 | outer_relid, |
| 1995 | outer_rel->rows); |
| 1996 | |
| 1997 | /* Remember smallest row count estimate among the outer rels */ |
| 1998 | if (result == 0.0 || result > rowcount) |
| 1999 | result = rowcount; |
| 2000 | } |
| 2001 | /* Return 1.0 if we found no valid relations (shouldn't happen) */ |
| 2002 | return (result > 0.0) ? result : 1.0; |
| 2003 | } |
| 2004 | |
| 2005 | /* |
| 2006 | * Check to see if outer_relid is on the inside of any semijoin that cur_relid |
no test coverage detected