Add missing optimizer hooks for function cost and number of rows.
Closely follow design of other optimizer hooks: if hook exists retrieve value from plugin; if still not set then get from cache.
This commit is contained in:
parent
491d1ea5b3
commit
473af39737
src
17
src/backend/utils/cache/lsyscache.c
vendored
17
src/backend/utils/cache/lsyscache.c
vendored
@ -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
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/cache/lsyscache.c,v 1.168 2010/02/26 02:01:11 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/cache/lsyscache.c,v 1.169 2010/04/23 22:23:39 sriggs Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* Eventually, the index information should go through here, too.
|
* Eventually, the index information should go through here, too.
|
||||||
@ -38,6 +38,9 @@
|
|||||||
/* Hook for plugins to get control in get_attavgwidth() */
|
/* Hook for plugins to get control in get_attavgwidth() */
|
||||||
get_attavgwidth_hook_type get_attavgwidth_hook = NULL;
|
get_attavgwidth_hook_type get_attavgwidth_hook = NULL;
|
||||||
|
|
||||||
|
/* Hook for plugins to get control in get_func_cost and get_func_rows */
|
||||||
|
get_func_cost_hook_type get_func_cost_hook = NULL;
|
||||||
|
get_func_rows_hook_type get_func_rows_hook = NULL;
|
||||||
|
|
||||||
/* ---------- AMOP CACHES ---------- */
|
/* ---------- AMOP CACHES ---------- */
|
||||||
|
|
||||||
@ -1409,6 +1412,12 @@ get_func_cost(Oid funcid)
|
|||||||
HeapTuple tp;
|
HeapTuple tp;
|
||||||
float4 result;
|
float4 result;
|
||||||
|
|
||||||
|
if (get_func_cost_hook)
|
||||||
|
{
|
||||||
|
result = (*get_func_cost_hook) (funcid);
|
||||||
|
if (result > (float4) 0)
|
||||||
|
return result;
|
||||||
|
}
|
||||||
tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
|
tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
|
||||||
if (!HeapTupleIsValid(tp))
|
if (!HeapTupleIsValid(tp))
|
||||||
elog(ERROR, "cache lookup failed for function %u", funcid);
|
elog(ERROR, "cache lookup failed for function %u", funcid);
|
||||||
@ -1428,6 +1437,12 @@ get_func_rows(Oid funcid)
|
|||||||
HeapTuple tp;
|
HeapTuple tp;
|
||||||
float4 result;
|
float4 result;
|
||||||
|
|
||||||
|
if (get_func_rows_hook)
|
||||||
|
{
|
||||||
|
result = (*get_func_rows_hook) (funcid);
|
||||||
|
if (result > (float4) 0)
|
||||||
|
return result;
|
||||||
|
}
|
||||||
tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
|
tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
|
||||||
if (!HeapTupleIsValid(tp))
|
if (!HeapTupleIsValid(tp))
|
||||||
elog(ERROR, "cache lookup failed for function %u", funcid);
|
elog(ERROR, "cache lookup failed for function %u", funcid);
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/include/utils/lsyscache.h,v 1.131 2010/01/04 02:44:40 tgl Exp $
|
* $PostgreSQL: pgsql/src/include/utils/lsyscache.h,v 1.132 2010/04/23 22:23:39 sriggs Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -30,6 +30,12 @@ typedef enum IOFuncSelector
|
|||||||
typedef int32 (*get_attavgwidth_hook_type) (Oid relid, AttrNumber attnum);
|
typedef int32 (*get_attavgwidth_hook_type) (Oid relid, AttrNumber attnum);
|
||||||
extern PGDLLIMPORT get_attavgwidth_hook_type get_attavgwidth_hook;
|
extern PGDLLIMPORT get_attavgwidth_hook_type get_attavgwidth_hook;
|
||||||
|
|
||||||
|
/* Hook for plugins to get control in get_func_cost and get_func_rows */
|
||||||
|
typedef float4 (*get_func_cost_hook_type) (Oid funcid);
|
||||||
|
extern PGDLLIMPORT get_func_cost_hook_type get_func_cost_hook;
|
||||||
|
typedef float4 (*get_func_rows_hook_type) (Oid funcid);
|
||||||
|
extern PGDLLIMPORT get_func_rows_hook_type get_func_rows_hook;
|
||||||
|
|
||||||
extern bool op_in_opfamily(Oid opno, Oid opfamily);
|
extern bool op_in_opfamily(Oid opno, Oid opfamily);
|
||||||
extern int get_op_opfamily_strategy(Oid opno, Oid opfamily);
|
extern int get_op_opfamily_strategy(Oid opno, Oid opfamily);
|
||||||
extern void get_op_opfamily_properties(Oid opno, Oid opfamily,
|
extern void get_op_opfamily_properties(Oid opno, Oid opfamily,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user