Further tweaking of logic that decides when to materialize an uncorrelated
subplan: do it if subplan has subplans itself, and always do it if the subplan is an indexscan. (I originally set it to materialize an indexscan only if the indexqual is fairly selective, but I dunno what I was thinking ... an unselective indexscan is still expensive ...)
This commit is contained in:
parent
bbe1ff7404
commit
e8be8ffaf0
@ -7,7 +7,7 @@
|
|||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/subselect.c,v 1.29 2000/03/02 04:08:16 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/subselect.c,v 1.30 2000/03/11 23:53:41 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -302,8 +302,8 @@ make_subplan(SubLink *slink)
|
|||||||
* the top of an uncorrelated/undirect correlated subplan, which lets
|
* the top of an uncorrelated/undirect correlated subplan, which lets
|
||||||
* us do the work of evaluating the subplan only once. We do this
|
* us do the work of evaluating the subplan only once. We do this
|
||||||
* if the subplan's top plan node is anything more complicated than
|
* if the subplan's top plan node is anything more complicated than
|
||||||
* a sequential or index scan, and we do it even for those plan types
|
* a plain sequential scan, and we do it even for seqscan if the
|
||||||
* if the qual appears selective enough to eliminate many tuples.
|
* qual appears selective enough to eliminate many tuples.
|
||||||
*/
|
*/
|
||||||
if (node->parParam == NIL)
|
if (node->parParam == NIL)
|
||||||
{
|
{
|
||||||
@ -312,28 +312,19 @@ make_subplan(SubLink *slink)
|
|||||||
switch (nodeTag(plan))
|
switch (nodeTag(plan))
|
||||||
{
|
{
|
||||||
case T_SeqScan:
|
case T_SeqScan:
|
||||||
|
if (plan->initPlan || plan->subPlan)
|
||||||
|
use_material = true;
|
||||||
|
else
|
||||||
{
|
{
|
||||||
Selectivity qualsel;
|
Selectivity qualsel;
|
||||||
|
|
||||||
qualsel = clauselist_selectivity(subquery, plan->qual, 0);
|
qualsel = clauselist_selectivity(subquery,
|
||||||
|
plan->qual,
|
||||||
|
0);
|
||||||
/* Is 10% selectivity a good threshold?? */
|
/* Is 10% selectivity a good threshold?? */
|
||||||
use_material = qualsel < 0.10;
|
use_material = qualsel < 0.10;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case T_IndexScan:
|
|
||||||
{
|
|
||||||
List *indxqual = ((IndexScan *) plan)->indxqualorig;
|
|
||||||
Selectivity qualsel;
|
|
||||||
|
|
||||||
qualsel = clauselist_selectivity(subquery, plan->qual, 0);
|
|
||||||
qualsel *= clauselist_selectivity(subquery, indxqual, 0);
|
|
||||||
/* Note: if index is lossy, we just double-counted the
|
|
||||||
* index selectivity. Worth fixing?
|
|
||||||
*/
|
|
||||||
/* Is 10% selectivity a good threshold?? */
|
|
||||||
use_material = qualsel < 0.10;
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case T_Material:
|
case T_Material:
|
||||||
case T_Sort:
|
case T_Sort:
|
||||||
/* Don't add another Material node if there's one already,
|
/* Don't add another Material node if there's one already,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user