diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c index 5ee37759..ead891a2 100644 --- a/src/backend/utils/adt/selfuncs.c +++ b/src/backend/utils/adt/selfuncs.c @@ -139,6 +139,8 @@ #include "utils/timestamp.h" #include "utils/typcache.h" +#include "portability/instr_time.h" + #define DEFAULT_PAGE_CPU_MULTIPLIER 50.0 /* @@ -374,6 +376,10 @@ var_eq_const(VariableStatData *vardata, Oid oproid, Oid collation, bool isdefault; Oid opfuncoid; + instr_time comparestart, + compareuration; + + INSTR_TIME_SET_CURRENT(comparestart); /* * If the constant is NULL, assume operator is strict and return zero, ie, * operator will never return TRUE. (It's zero even for a negator op.) @@ -426,6 +432,8 @@ var_eq_const(VariableStatData *vardata, Oid oproid, Oid collation, LOCAL_FCINFO(fcinfo, 2); FmgrInfo eqproc; + + fmgr_info(opfuncoid, &eqproc); /* @@ -527,6 +535,18 @@ var_eq_const(VariableStatData *vardata, Oid oproid, Oid collation, /* result should be in range, but make sure... */ CLAMP_PROBABILITY(selec); + { + double plantime; + + INSTR_TIME_SET_CURRENT(compareuration); + INSTR_TIME_SUBTRACT(compareuration, comparestart); + plantime = INSTR_TIME_GET_DOUBLE(compareuration); + + elog(NOTICE, "var_eq_cosnt() : %.*f", + 3, 1000.0 * plantime); + + } + return selec; } @@ -812,6 +832,11 @@ mcv_selectivity(VariableStatData *vardata, FmgrInfo *opproc, Oid collation, AttStatsSlot sslot; int i; + instr_time comparestart, + compareuration; + + INSTR_TIME_SET_CURRENT(comparestart); + mcv_selec = 0.0; sumcommon = 0.0; @@ -858,6 +883,20 @@ mcv_selectivity(VariableStatData *vardata, FmgrInfo *opproc, Oid collation, } *sumcommonp = sumcommon; + + { + double plantime; + + INSTR_TIME_SET_CURRENT(compareuration); + INSTR_TIME_SUBTRACT(compareuration, comparestart); + plantime = INSTR_TIME_GET_DOUBLE(compareuration); + + + elog(NOTICE, "mcv_selectivity(opproc->fn_oid=%d) : %.*f", + opproc->fn_oid, 3, 1000.0 * plantime); + + } + return mcv_selec; } @@ -2419,6 +2458,12 @@ eqjoinsel(PG_FUNCTION_ARGS) bool join_is_reversed; RelOptInfo *inner_rel; + /* just for perf test*/ + instr_time comparestart, + compareuration; + + INSTR_TIME_SET_CURRENT(comparestart); + get_join_variables(root, args, sjinfo, &vardata1, &vardata2, &join_is_reversed); @@ -2476,7 +2521,8 @@ eqjoinsel(PG_FUNCTION_ARGS) * If the MCV lists are long enough to justify hashing, try to look up * hash functions for the join operator. */ - if ((sslot1.nvalues + sslot2.nvalues) >= EQJOINSEL_MCV_HASH_THRESHOLD) + /* if ((sslot1.nvalues + sslot2.nvalues) >= EQJOINSEL_MCV_HASH_THRESHOLD) */ + if ((sslot1.nvalues + sslot2.nvalues) >= 202) /* just for perf test*/ (void) get_op_hash_functions_ext(operator, exprType((Node *) linitial(args)), &hashLeft, &hashRight); @@ -2574,6 +2620,16 @@ eqjoinsel(PG_FUNCTION_ARGS) CLAMP_PROBABILITY(selec); + { + double plantime; + + INSTR_TIME_SET_CURRENT(compareuration); + INSTR_TIME_SUBTRACT(compareuration, comparestart); + plantime = INSTR_TIME_GET_DOUBLE(compareuration); + + elog(NOTICE, "eqjoinsel() : %.*f", 3, 1000.0 * plantime); + } + PG_RETURN_FLOAT8((float8) selec); } @@ -3347,6 +3403,11 @@ mergejoinscansel(PlannerInfo *root, Node *clause, rightmin, rightmax; double selec; + /* just for perf test*/ + instr_time comparestart, + compareuration; + + INSTR_TIME_SET_CURRENT(comparestart); /* Set default results if we can't figure anything out. */ /* XXX should default "start" fraction be a bit more than 0? */ @@ -3615,6 +3676,16 @@ mergejoinscansel(PlannerInfo *root, Node *clause, *rightend = 1.0; } + { + double plantime; + + INSTR_TIME_SET_CURRENT(compareuration); + INSTR_TIME_SUBTRACT(compareuration, comparestart); + plantime = INSTR_TIME_GET_DOUBLE(compareuration); + + elog(NOTICE, "mergejoinscansel() : %.*f", 3, 1000.0 * plantime); + } + fail: ReleaseVariableStats(leftvar); ReleaseVariableStats(rightvar);