[postgis-devel] [PostGIS] #1828: Estimate returned by geography_gist_selectivity results in slow query plan for ST_DWithin
PostGIS
trac at osgeo.org
Tue Nov 20 10:40:41 PST 2012
#1828: Estimate returned by geography_gist_selectivity results in slow query plan
for ST_DWithin
---------------------------+------------------------------------------------
Reporter: realityexists | Owner: mcayland
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.0.2
Component: postgis | Version: 2.0.x
Keywords: |
---------------------------+------------------------------------------------
Comment(by pramsey):
OK, back looking at this *particular* problem, avoiding thinking about
handling <func>, just trying to get the selectivity in this case working
better...
First question: can we just avoid returning an answer when we are in a
"don't know" situation. Answer: No. The caller is expecting a valid
number, and will error out if we don't deliver (plancat.c:1033):
{{{
if (result < 0.0 || result > 1.0)
elog(ERROR, "invalid restriction selectivity: %f",
result);
}}}
Second question: surely the PgSQL planner has to deal with unknowns! What
do they do? Answer: Well, there's an example one caller up from plancat.c,
in (clausesel.c:683)
{{{
else if (is_funcclause(clause))
{
/*
* This is not an operator, so we guess at the
selectivity. THIS IS A
* HACK TO GET V4 OUT THE DOOR. FUNCS SHOULD BE ABLE TO
HAVE
* SELECTIVITIES THEMSELVES. -- JMH 7/9/92
*/
s1 = (Selectivity) 0.3333333;
}
}}}
So, they return a mid-range value when they don't know, presumably to let
other extreme values one way or the other weigh in first.
--
Ticket URL: <http://trac.osgeo.org/postgis/ticket/1828#comment:48>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.
More information about the postgis-devel
mailing list