• M
    Fixes: · 796f7899
    Marc G. Fournier 提交于
    The problem is that the function arguments are not considered as possible key
    candidates for index scan and so only a sequential scan is possible inside
    the body of a function.  I have therefore made some patches to the optimizer
    so that indices are now used also by functions.  I have also moved the plan
    debug message from pg_eval to pg_plan so that it is printed also for plans
    genereated for function execution.  I had also to add an index rescan to the
    executor because it ignored the parameters set in the execution state, they
    were flagged as runtime variables in ExecInitIndexScan but then never used
    by the executor so that the scan were always done with any key=1. Very odd.
    This means that an index rescan is now done twice for each function execution
    which uses an index, the first time when the index scan is initialized and
    the second when the actual function arguments are finally available for the
    execution.  I don't know what is the cost of an double index scan but I
    suppose it is anyway less than the cost of a full sequential scan, at leat
    for large tables. This is my patch, you must also add -DINDEXSCAN_PATCH in
    Makefile.global to enable the changes.
    
    Submitted by: Massimo Dal Zotto <dz@cs.unitn.it>
    796f7899
createplan.c 29.4 KB