[svn-commits] r138 - in branches/advisor/src/back: opf/opj opf/opv opf/opz scf/hdr scf/scd scf/scm scf/scs
thial01 at ingres.com
thial01 at ingres.com
Thu Jul 3 05:00:04 PDT 2008
Author: thial01
Date: 2008-07-03 05:00:03 -0700 (Thu, 03 Jul 2008)
New Revision: 138
Modified:
branches/advisor/src/back/opf/opj/opjjoinop.c
branches/advisor/src/back/opf/opv/opvindex.c
branches/advisor/src/back/opf/opv/opvparser.c
branches/advisor/src/back/opf/opz/opzaddatts.c
branches/advisor/src/back/scf/hdr/scm.h
branches/advisor/src/back/scf/scd/scdmain.c
branches/advisor/src/back/scf/scm/scmima.c
branches/advisor/src/back/scf/scm/scmmain.c
branches/advisor/src/back/scf/scs/scsqncr.c
Log:
Adding log functions for attributes and indexes - see #174
Modified: branches/advisor/src/back/opf/opj/opjjoinop.c
===================================================================
--- branches/advisor/src/back/opf/opj/opjjoinop.c 2008-07-02 13:51:12 UTC (rev 137)
+++ branches/advisor/src/back/opf/opj/opjjoinop.c 2008-07-03 12:00:03 UTC (rev 138)
@@ -6092,6 +6092,36 @@
** up yet */
subqpp = opj_enum(subqpp); /* find best plan and
** ptr to next subquery to optimize */
+
+ /*
+ ** Log cost estimates for this query.
+ ** But not all queries seem to produce a bestco plan
+ ** so let's check for it first
+ */
+ if (global->ops_subquery->ops_bestco != NULL)
+ {
+ scm_log_stm_cost(
+ (i4) (global->ops_subquery->ops_bestco->opo_cost.opo_cpu
+ / global->ops_cb->ops_alter.ops_cpufactor),
+ (i4) global->ops_subquery->ops_bestco->opo_cost.opo_dio,
+ (i4) global->ops_subquery->ops_bestco->opo_cost.opo_pagestouched );
+ }
+
+ /* And also log the indexes used in this QEP */
+ i4 i;
+ for (i = 0; i < global->ops_rangetab.opv_gv; i++)
+ {
+ i4 db_tab_index;
+ db_tab_index = global->ops_rangetab.opv_base->opv_grv[i]->
+ opv_relation->rdr_rel->tbl_id.db_tab_index;
+
+ /* Check if this is an index */
+ if (db_tab_index > 0)
+ {
+ scm_log_used_index(db_tab_index);
+ }
+ }
+
}
/* Call partition analyzer to break up partitioned table
Modified: branches/advisor/src/back/opf/opv/opvindex.c
===================================================================
--- branches/advisor/src/back/opf/opv/opvindex.c 2008-07-02 13:51:12 UTC (rev 137)
+++ branches/advisor/src/back/opf/opv/opvindex.c 2008-07-03 12:00:03 UTC (rev 138)
@@ -1426,6 +1426,19 @@
owner = &gvar_ptr->opv_relation->rdr_rel->tbl_owner;
for( ituple = gvar_ptr->opv_relation->rdr_rel->tbl_index_count;
ituple-- ;)
+ {
+ /* Log the index for the design analyzer */
+ scm_log_index(
+ gvar_ptr->opv_relation->rdr_indx[ituple]->idx_id.db_tab_index,
+ gvar_ptr->opv_relation->rdr_indx[ituple]->idx_name.db_tab_name,
+ gvar_ptr->opv_relation->rdr_indx[ituple]->idx_id.db_tab_base,
+ gvar_ptr->opv_relation->rdr_indx[ituple]->idx_attr_id[0], /* FIXME - no support
+ ** for multi column indexes
+ */
+ 0, /* FIXME */
+ 0, /* FIXME */
+ gvar_ptr->opv_relation->rdr_indx[ituple]->idx_storage_type );
+
opv_uindex(subquery, var, owner, ituple, &gotsub,
gvar_ptr->opv_relation->rdr_indx[ituple],
prim_keys,
@@ -1433,6 +1446,7 @@
** the index is useful and add it to
** the local range table if it is
*/
+ }
}
}
if (subquery->ops_dist.opd_updtsj != OPV_NOVAR)
Modified: branches/advisor/src/back/opf/opv/opvparser.c
===================================================================
--- branches/advisor/src/back/opf/opv/opvparser.c 2008-07-02 13:51:12 UTC (rev 137)
+++ branches/advisor/src/back/opf/opv/opvparser.c 2008-07-03 12:00:03 UTC (rev 138)
@@ -530,6 +530,15 @@
status = rdf_call( RDF_GETDESC, (PTR)rdfcb);
grvp->opv_relation = rdfcb->rdf_info_blk; /* save ptr to
** new info block */
+
+ /* Log this table for the design analyzer */
+ scm_log_table(
+ grvp->opv_relation->rdr_rel->tbl_id.db_tab_base,
+ grvp->opv_relation->rdr_rel->tbl_name.db_tab_name,
+ grvp->opv_relation->rdr_rel->tbl_dpage_count,
+ grvp->opv_relation->rdr_rel->tbl_opage_count,
+ grvp->opv_relation->rdr_rel->tbl_storage_type );
+
if ((status != E_RD0000_OK)
&&
(rdfcb->rdf_error.err_code != E_RD026A_OBJ_INDEXCOUNT) /* this
Modified: branches/advisor/src/back/opf/opz/opzaddatts.c
===================================================================
--- branches/advisor/src/back/opf/opz/opzaddatts.c 2008-07-02 13:51:12 UTC (rev 137)
+++ branches/advisor/src/back/opf/opz/opzaddatts.c 2008-07-03 12:00:03 UTC (rev 138)
@@ -248,6 +248,17 @@
datatype->db_length = rel->rdr_attr[dmfattr]->att_width;
}
+ if ( rel != NULL
+ &&
+ rel->rdr_attr[dmfattr] != NULL )
+ {
+ /* Log the attribute for the design analyzer */
+ scm_log_attribute(
+ rel->rdr_rel->tbl_id.db_tab_base,
+ dmfattr,
+ rel->rdr_attr[dmfattr]->att_name.db_att_name );
+ }
+
attr_ptr->opz_varnm = joinopvar; /* index into local range table */
BTset( (i4)nextattr, (char *)&var_ptr->opv_attrmap); /* indicate
** that this joinop
Modified: branches/advisor/src/back/scf/hdr/scm.h
===================================================================
--- branches/advisor/src/back/scf/hdr/scm.h 2008-07-02 13:51:12 UTC (rev 137)
+++ branches/advisor/src/back/scf/hdr/scm.h 2008-07-03 12:00:03 UTC (rev 138)
@@ -29,7 +29,7 @@
/* IMA index definitions */
static char scm_stm_index_class[] = "exp.scf.scm.stm.index";
static char scm_tab_index_class[] = "exp.scf.scm.tab.index";
-static char scm_col_index_class[] = "exp.scf.scm.col.index";
+static char scm_atr_index_class[] = "exp.scf.scm.atr.index";
static char scm_idx_index_class[] = "exp.scf.scm.idx.index";
static char scm_ref_index_class[] = "exp.scf.scm.ref.index";
static char scm_sts_index_class[] = "exp.scf.scm.sts.index";
@@ -46,13 +46,17 @@
*/
typedef struct _SCM_STATEMENT
{
- char database[DB_MAXNAME];
- u_i4 query_key;
- char query_text[MAXQUERYLEN];
- i4 frequency;
- i4 cost;
- i4 opf_time;
- i4 qef_time;
+ char database[DB_MAXNAME];
+ u_i4 query_key;
+ char query_text[MAXQUERYLEN];
+ u_i4 frequency;
+ u_i4 opf_cpu;
+ u_i4 opf_dio;
+ u_i4 qef_cpu;
+ u_i4 qef_dio;
+ u_i4 est_cpu;
+ u_i4 est_dio;
+ u_i4 pages_touched;
} SCM_STATEMENT;
/*}
@@ -67,42 +71,42 @@
*/
typedef struct _SCM_TABLE
{
- char database[DB_MAXNAME];
- i4 table_id;
- char name[DB_MAXNAME];
- i4 frequency;
- char statistics;
- i4 est_cpu;
- i4 act_cpu;
- i4 est_dio;
- i4 act_dio;
- i4 est_tup;
- i4 act_tup;
- i4 structure;
- i4 data_pages;
- i4 overflow_pages;
+ char database[DB_MAXNAME];
+ i4 table_id;
+ char name[DB_MAXNAME];
+ u_i4 frequency;
+ char statistics;
+ u_i4 est_cpu;
+ u_i4 act_cpu;
+ u_i4 est_dio;
+ u_i4 act_dio;
+ u_i4 est_tup;
+ u_i4 act_tup;
+ i4 structure;
+ u_i4 data_pages;
+ u_i4 overflow_pages;
} SCM_TABLE;
/*}
-** Name: SCM_COLUMN - Structure to hold column data for monitoring
+** Name: SCM_ATTRIBUTE - Structure to hold attribute data for monitoring
**
** Description:
-** This structure contains the columns that were referenced
+** This structure contains the attributes that were referenced
**
** History:
** 26-Jun-2008 (thial01)
** Structur created
*/
-typedef struct _SCM_COLUMN
+typedef struct _SCM_ATTRIBUTE
{
char database[DB_MAXNAME];
- i4 column_id;
+ i4 attribute_id;
char name[DB_MAXNAME];
i4 table_id;
- i4 frequency;
+ u_i4 frequency;
-} SCM_COLUMN;
+} SCM_ATTRIBUTE;
/*}
** Name: SCM_INDEX - Structure to hold index data for monitoring
@@ -116,15 +120,15 @@
*/
typedef struct _SCM_INDEX
{
- char database[DB_MAXNAME];
- i4 index_id;
- char name[DB_MAXNAME];
- i4 table_id;
- i4 column_id;
- i4 frequency;
- i4 structure;
- i4 data_pages;
- i4 overflow_pages;
+ char database[DB_MAXNAME];
+ i4 index_id;
+ char name[DB_MAXNAME];
+ i4 table_id;
+ i4 attribute_id;
+ u_i4 frequency;
+ i4 structure;
+ u_i4 data_pages;
+ u_i4 overflow_pages;
} SCM_INDEX;
@@ -133,7 +137,7 @@
**
** Description:
** This structure contains the references between statements
-** and tables, columns, indexes
+** and tables, attributes, indexes
**
** History:
** 26-Jun-2008 (thial01)
@@ -144,7 +148,7 @@
/*
** This struct is used as a relation between a statement
** and the database object referenced in the statement.
- ** Every table, column, index gets an entry here
+ ** Every table, attribute, index gets an entry here
** so that the design analyzer knows what db objects
** need to be looked at to optimize a query
*/
@@ -154,12 +158,12 @@
/* Type of the object that is referenced */
#define SCM_TYPE_TABLE 0
-#define SCM_TYPE_COLUMN 1
+#define SCM_TYPE_ATTR 1
#define SCM_TYPE_INDEX 2
i4 object_type;
i4 object_id;
- i4 table_id; /* Needed to reference the correct column */
+ i4 table_id; /* Needed to reference the correct attribute */
} SCM_REFERENCE;
@@ -200,15 +204,15 @@
SCM_TABLE *tables[MAXMONITOR];
i4 cur_tab_idx; /* The position in the array */
- SCM_COLUMN *columns[MAXMONITOR];
- i4 cur_col_idx; /* The position in the array */
+ SCM_ATTRIBUTE *attributes[MAXMONITOR];
+ i4 cur_atr_idx; /* The position in the array */
SCM_INDEX *indexes[MAXMONITOR];
i4 cur_idx_idx; /* The position in the array */
/*
** The upper bound of references would be the sum of all
- ** tables, columns and indexes times the number of statements.
+ ** tables, attributes and indexes times the number of statements.
** However 2*MAXMONITOR should be enough...
*/
SCM_REFERENCE *references[MAXMONITOR*2];
Modified: branches/advisor/src/back/scf/scd/scdmain.c
===================================================================
--- branches/advisor/src/back/scf/scd/scdmain.c 2008-07-02 13:51:12 UTC (rev 137)
+++ branches/advisor/src/back/scf/scd/scdmain.c 2008-07-03 12:00:03 UTC (rev 138)
@@ -627,9 +627,6 @@
if( !STcasecmp( server_type, "dbms" ) )
{
Sc_server_type = SC_INGRES_SERVER;
-
- // Init dbms monitor
-// scm_init();
}
else if( !STcasecmp( server_type, "rms" ) )
{
Modified: branches/advisor/src/back/scf/scm/scmima.c
===================================================================
--- branches/advisor/src/back/scf/scm/scmima.c 2008-07-02 13:51:12 UTC (rev 137)
+++ branches/advisor/src/back/scf/scm/scmima.c 2008-07-03 12:00:03 UTC (rev 138)
@@ -102,23 +102,47 @@
0, MOidata_index
},
{
- MO_CDATA_INDEX, "exp.scf.scm.stm.cost",
- MO_SIZEOF_MEMBER(SCM_STATEMENT, cost), MO_READ, scm_stm_index_class,
- CL_OFFSETOF(SCM_STATEMENT, cost), MOuintget, MOnoset,
+ MO_CDATA_INDEX, "exp.scf.scm.stm.opf_cpu",
+ MO_SIZEOF_MEMBER(SCM_STATEMENT, opf_cpu), MO_READ, scm_stm_index_class,
+ CL_OFFSETOF(SCM_STATEMENT, opf_cpu), MOuintget, MOnoset,
0, MOidata_index
},
{
- MO_CDATA_INDEX, "exp.scf.scm.stm.opf_time",
- MO_SIZEOF_MEMBER(SCM_STATEMENT, opf_time), MO_READ, scm_stm_index_class,
- CL_OFFSETOF(SCM_STATEMENT, opf_time), MOuintget, MOnoset,
+ MO_CDATA_INDEX, "exp.scf.scm.stm.opf_dio",
+ MO_SIZEOF_MEMBER(SCM_STATEMENT, opf_dio), MO_READ, scm_stm_index_class,
+ CL_OFFSETOF(SCM_STATEMENT, opf_dio), MOuintget, MOnoset,
0, MOidata_index
},
{
- MO_CDATA_INDEX, "exp.scf.scm.stm.qef_time",
- MO_SIZEOF_MEMBER(SCM_STATEMENT, qef_time), MO_READ, scm_stm_index_class,
- CL_OFFSETOF(SCM_STATEMENT, qef_time), MOuintget, MOnoset,
+ MO_CDATA_INDEX, "exp.scf.scm.stm.qef_cpu",
+ MO_SIZEOF_MEMBER(SCM_STATEMENT, qef_cpu), MO_READ, scm_stm_index_class,
+ CL_OFFSETOF(SCM_STATEMENT, qef_cpu), MOuintget, MOnoset,
0, MOidata_index
},
+ {
+ MO_CDATA_INDEX, "exp.scf.scm.stm.qef_dio",
+ MO_SIZEOF_MEMBER(SCM_STATEMENT, qef_dio), MO_READ, scm_stm_index_class,
+ CL_OFFSETOF(SCM_STATEMENT, qef_dio), MOuintget, MOnoset,
+ 0, MOidata_index
+ },
+ {
+ MO_CDATA_INDEX, "exp.scf.scm.stm.est_cpu",
+ MO_SIZEOF_MEMBER(SCM_STATEMENT, est_cpu), MO_READ, scm_stm_index_class,
+ CL_OFFSETOF(SCM_STATEMENT, est_cpu), MOuintget, MOnoset,
+ 0, MOidata_index
+ },
+ {
+ MO_CDATA_INDEX, "exp.scf.scm.stm.est_dio",
+ MO_SIZEOF_MEMBER(SCM_STATEMENT, est_dio), MO_READ, scm_stm_index_class,
+ CL_OFFSETOF(SCM_STATEMENT, est_dio), MOuintget, MOnoset,
+ 0, MOidata_index
+ },
+ {
+ MO_CDATA_INDEX, "exp.scf.scm.stm.pages_touched",
+ MO_SIZEOF_MEMBER(SCM_STATEMENT, pages_touched), MO_READ, scm_stm_index_class,
+ CL_OFFSETOF(SCM_STATEMENT, pages_touched), MOuintget, MOnoset,
+ 0, MOidata_index
+ },
{ 0 }
};
@@ -133,7 +157,7 @@
{
MO_CDATA_INDEX, "exp.scf.scm.tab.id",
MO_SIZEOF_MEMBER(SCM_TABLE, table_id), MO_READ, scm_tab_index_class,
- CL_OFFSETOF(SCM_TABLE, table_id), MOuintget, MOnoset,
+ CL_OFFSETOF(SCM_TABLE, table_id), MOintget, MOnoset,
0, MOidata_index
},
{
@@ -193,7 +217,7 @@
{
MO_CDATA_INDEX, "exp.scf.scm.tab.structure",
MO_SIZEOF_MEMBER(SCM_TABLE, structure), MO_READ, scm_tab_index_class,
- CL_OFFSETOF(SCM_TABLE, structure), MOuintget, MOnoset,
+ CL_OFFSETOF(SCM_TABLE, structure), MOintget, MOnoset,
0, MOidata_index
},
{
@@ -211,42 +235,42 @@
{ 0 }
};
-static MO_CLASS_DEF scf_scm_col_classes[] =
+static MO_CLASS_DEF scf_scm_atr_classes[] =
{
{
- MO_CDATA_CLASSID|MO_CDATA_INDEX, scm_col_index_class,
+ MO_CDATA_CLASSID|MO_CDATA_INDEX, scm_atr_index_class,
0, MO_READ, 0,
0, MOpvget, MOnoset,
0, MOidata_index
},
{
- MO_CDATA_INDEX, "exp.scf.scm.col.id",
- MO_SIZEOF_MEMBER(SCM_COLUMN, column_id), MO_READ, scm_col_index_class,
- CL_OFFSETOF(SCM_COLUMN, column_id), MOuintget, MOnoset,
+ MO_CDATA_INDEX, "exp.scf.scm.atr.id",
+ MO_SIZEOF_MEMBER(SCM_ATTRIBUTE, attribute_id), MO_READ, scm_atr_index_class,
+ CL_OFFSETOF(SCM_ATTRIBUTE, attribute_id), MOintget, MOnoset,
0, MOidata_index
},
{
- MO_CDATA_INDEX, "exp.scf.scm.col.database",
- MO_SIZEOF_MEMBER(SCM_COLUMN, database), MO_READ, scm_col_index_class,
- CL_OFFSETOF(SCM_COLUMN, database), MOstrget, MOnoset,
+ MO_CDATA_INDEX, "exp.scf.scm.atr.database",
+ MO_SIZEOF_MEMBER(SCM_ATTRIBUTE, database), MO_READ, scm_atr_index_class,
+ CL_OFFSETOF(SCM_ATTRIBUTE, database), MOstrget, MOnoset,
0, MOidata_index
},
{
- MO_CDATA_INDEX, "exp.scf.scm.col.name",
- MO_SIZEOF_MEMBER(SCM_COLUMN, name), MO_READ, scm_col_index_class,
- CL_OFFSETOF(SCM_COLUMN, name), MOstrget, MOnoset,
+ MO_CDATA_INDEX, "exp.scf.scm.atr.name",
+ MO_SIZEOF_MEMBER(SCM_ATTRIBUTE, name), MO_READ, scm_atr_index_class,
+ CL_OFFSETOF(SCM_ATTRIBUTE, name), MOstrget, MOnoset,
0, MOidata_index
},
{
- MO_CDATA_INDEX, "exp.scf.scm.col.table_id",
- MO_SIZEOF_MEMBER(SCM_COLUMN, table_id), MO_READ, scm_col_index_class,
- CL_OFFSETOF(SCM_COLUMN, table_id), MOuintget, MOnoset,
+ MO_CDATA_INDEX, "exp.scf.scm.atr.table_id",
+ MO_SIZEOF_MEMBER(SCM_ATTRIBUTE, table_id), MO_READ, scm_atr_index_class,
+ CL_OFFSETOF(SCM_ATTRIBUTE, table_id), MOintget, MOnoset,
0, MOidata_index
},
{
- MO_CDATA_INDEX, "exp.scf.scm.col.frequency",
- MO_SIZEOF_MEMBER(SCM_COLUMN, frequency), MO_READ, scm_col_index_class,
- CL_OFFSETOF(SCM_COLUMN, frequency), MOuintget, MOnoset,
+ MO_CDATA_INDEX, "exp.scf.scm.atr.frequency",
+ MO_SIZEOF_MEMBER(SCM_ATTRIBUTE, frequency), MO_READ, scm_atr_index_class,
+ CL_OFFSETOF(SCM_ATTRIBUTE, frequency), MOuintget, MOnoset,
0, MOidata_index
},
{ 0 }
@@ -262,8 +286,8 @@
},
{
MO_CDATA_INDEX, "exp.scf.scm.idx.id",
- MO_SIZEOF_MEMBER(SCM_INDEX, column_id), MO_READ, scm_idx_index_class,
- CL_OFFSETOF(SCM_INDEX, column_id), MOuintget, MOnoset,
+ MO_SIZEOF_MEMBER(SCM_INDEX, attribute_id), MO_READ, scm_idx_index_class,
+ CL_OFFSETOF(SCM_INDEX, attribute_id), MOintget, MOnoset,
0, MOidata_index
},
{
@@ -281,13 +305,13 @@
{
MO_CDATA_INDEX, "exp.scf.scm.idx.table_id",
MO_SIZEOF_MEMBER(SCM_INDEX, table_id), MO_READ, scm_idx_index_class,
- CL_OFFSETOF(SCM_INDEX, table_id), MOuintget, MOnoset,
+ CL_OFFSETOF(SCM_INDEX, table_id), MOintget, MOnoset,
0, MOidata_index
},
{
- MO_CDATA_INDEX, "exp.scf.scm.idx.column_id",
- MO_SIZEOF_MEMBER(SCM_INDEX, column_id), MO_READ, scm_idx_index_class,
- CL_OFFSETOF(SCM_INDEX, column_id), MOuintget, MOnoset,
+ MO_CDATA_INDEX, "exp.scf.scm.idx.attribute_id",
+ MO_SIZEOF_MEMBER(SCM_INDEX, attribute_id), MO_READ, scm_idx_index_class,
+ CL_OFFSETOF(SCM_INDEX, attribute_id), MOintget, MOnoset,
0, MOidata_index
},
{
@@ -299,7 +323,7 @@
{
MO_CDATA_INDEX, "exp.scf.scm.idx.structure",
MO_SIZEOF_MEMBER(SCM_INDEX, structure), MO_READ, scm_idx_index_class,
- CL_OFFSETOF(SCM_INDEX, structure), MOuintget, MOnoset,
+ CL_OFFSETOF(SCM_INDEX, structure), MOintget, MOnoset,
0, MOidata_index
},
{
@@ -334,7 +358,7 @@
{
MO_CDATA_INDEX, "exp.scf.scm.ref.query_key",
MO_SIZEOF_MEMBER(SCM_REFERENCE, query_key), MO_READ, scm_ref_index_class,
- CL_OFFSETOF(SCM_REFERENCE, query_key), MOintget, MOnoset,
+ CL_OFFSETOF(SCM_REFERENCE, query_key), MOuintget, MOnoset,
0, MOidata_index
},
{
@@ -408,7 +432,7 @@
// Make the MO classes known to MO
MOclassdef(MAXI2, scf_scm_stm_classes);
MOclassdef(MAXI2, scf_scm_tab_classes);
- MOclassdef(MAXI2, scf_scm_col_classes);
+ MOclassdef(MAXI2, scf_scm_atr_classes);
MOclassdef(MAXI2, scf_scm_idx_classes);
MOclassdef(MAXI2, scf_scm_ref_classes);
MOclassdef(MAXI2, scf_scm_sts_classes);
Modified: branches/advisor/src/back/scf/scm/scmmain.c
===================================================================
--- branches/advisor/src/back/scf/scm/scmmain.c 2008-07-02 13:51:12 UTC (rev 137)
+++ branches/advisor/src/back/scf/scm/scmmain.c 2008-07-03 12:00:03 UTC (rev 138)
@@ -97,7 +97,8 @@
*/
u_i4
-scm_hash(char *query_text)
+scm_hash(
+ char *query_text)
{
u_i4 hashkey;
i4 len;
@@ -111,6 +112,37 @@
}
/*{
+** Name: scm_get_scb - Get the current scb
+**
+** Description:
+** This functions returns the current session control block
+**
+** Inputs:
+** none.
+**
+** Outputs:
+** none.
+**
+** Returns:
+** scb current session cuntrol block
+**
+** History:
+** 30-Jun-2008 (thial01)
+** created
+*/
+
+SCD_SCB*
+scm_get_scb( VOID )
+{
+
+ CS_SID sid;
+
+ CSget_sid(&sid);
+ return (SCD_SCB*)CSfind_scb(sid);
+
+}
+
+/*{
** Name: scm_stmt_lookup - Search for a statement
**
** Description:
@@ -133,9 +165,11 @@
*/
SCM_STATEMENT*
-scm_stmt_lookup(char *db_name, u_i4 hashkey)
+scm_stmt_lookup(
+ char *db_name,
+ u_i4 hashkey )
{
- int i;
+ i4 i;
for (i = 0; i < MAXMONITOR; i++)
{
@@ -145,8 +179,7 @@
} else if (
Sc_main_cb->scm.statements[i]->query_key == hashkey
&&
- STncmp(Sc_main_cb->scm.statements[i]->database, db_name, DB_MAXNAME-1) == 0
- )
+ STncmp(Sc_main_cb->scm.statements[i]->database, db_name, DB_MAXNAME-1) == 0 )
{
return (SCM_STATEMENT*)Sc_main_cb->scm.statements[i];
}
@@ -176,17 +209,14 @@
*/
SCM_STATEMENT*
-scm_get_cur_stmt(VOID)
+scm_get_cur_stmt( VOID )
{
- CS_SID sid;
- SCD_SCB *scb;
+ SCD_SCB *scb;
SCM_STATEMENT *stmt;
- u_i4 key;
- char *db_name;
+ u_i4 key;
+ char *db_name;
- /* Get the session control block */
- CSget_sid(&sid);
- scb = (SCD_SCB*)CSfind_scb(sid);
+ scb = scm_get_scb();
db_name = scb->scb_sscb.sscb_ics.ics_dbname.db_db_name;
key = scb->scm_current_stmt;
@@ -219,22 +249,18 @@
*/
VOID
-scm_log_stmt(VOID)
+scm_log_stmt( VOID )
{
DB_STATUS status;
- PTR block;
- char *query_text;
- char *db_name;
- u_i4 hashkey;
- SCM *scm;
- SCM_STATEMENT *statement;
- CS_SID sid;
- SCD_SCB *scb;
+ char *query_text;
+ char *db_name;
+ u_i4 hashkey;
+ SCM *scm;
+ SCM_STATEMENT *statement;
+ SCD_SCB *scb;
+
+ scb = scm_get_scb();
- /* Get the session control block */
- CSget_sid(&sid);
- scb = (SCD_SCB*)CSfind_scb(sid);
-
scm = &Sc_main_cb->scm;
/* Plain text of the current query */
@@ -317,6 +343,8 @@
/* We saw it before, so just increment the counter */
statement->frequency += 1;
}
+
+ return;
}
@@ -324,10 +352,11 @@
** Name: scm_log_opf_time - Log the time in OPF
**
** Description:
-** This functions logs the time the statement needs for optimization
+** This functions logs the cpu and dio the statement needs for optimization
**
** Inputs:
-** time The time in seconds
+** start TIMERSTAT start
+** end TIMERSTAT end
**
** Outputs:
** none.
@@ -341,7 +370,9 @@
*/
VOID
-scm_log_opf_time(i4 time)
+scm_log_opf_time(
+ TIMERSTAT *start,
+ TIMERSTAT *end )
{
SCM_STATEMENT *scm;
@@ -354,18 +385,25 @@
return;
}
- scm->opf_time = time;
+ scm->opf_cpu =
+ end->stat_cpu - start->stat_cpu;
+
+ scm->opf_dio =
+ end->stat_dio - start->stat_dio;
+ return;
+
}
/*{
** Name: scm_log_qef_time - Log the time in QEF
**
** Description:
-** This functions logs the time the statement needs for execution
+** This functions logs the cpu and dio the statement needs for execution
**
** Inputs:
-** time The time in seconds
+** start TIMERSTAT start
+** end TIMERSTAT end
**
** Outputs:
** none.
@@ -379,19 +417,791 @@
*/
VOID
-scm_log_qef_time(i4 time)
+scm_log_qef_time(
+ TIMERSTAT *start,
+ TIMERSTAT *end )
{
SCM_STATEMENT *scm;
/* Get the struct of the current statement */
scm = scm_get_cur_stmt();
+
+ if (scm == NULL)
+ {
+ return;
+ }
+ scm->qef_cpu =
+ end->stat_cpu - start->stat_cpu;
+ scm->qef_cpu =
+ end->stat_dio - start->stat_dio;
+
+ return;
+
+}
+
+/*{
+** Name: scm_log_stm_cost - Log the cost of the statement
+**
+** Description:
+** This functions logs the overall cost of the statement
+**
+** Inputs:
+** cpu estimated cpu cost
+** dio estimated dop cost
+** touched estimated count of touched tuples
+**
+** Outputs:
+** none.
+**
+** Returns:
+** none.
+**
+** History:
+** 02-Jul-2008 (thial01)
+** created
+*/
+
+VOID
+scm_log_stm_cost(
+ i4 cpu,
+ i4 dio,
+ i4 touched )
+{
+
+ SCM_STATEMENT *scm;
+
+ /* Get the struct of the current statement */
+ scm = scm_get_cur_stmt();
+
if (scm == NULL)
{
return;
+ }
+
+ scm->est_cpu = cpu;
+ scm->est_dio = dio;
+ scm->pages_touched = touched;
+
+ return;
+
+}
+
+/*{
+** Name: scm_log_reference - Log a reference
+**
+** Description:
+** This functions logs the reference between a db object and a statement
+**
+** Inputs:
+** none.
+**
+** Outputs:
+** none.
+**
+** Returns:
+** none.
+**
+** History:
+** 30-Jun-2008 (thial01)
+** created
+*/
+
+VOID
+scm_log_reference(
+ i4 object_type,
+ i4 object_id,
+ i4 table_id )
+{
+ DB_STATUS status;
+ SCM *scm;
+ SCM_STATEMENT *stm;
+ SCM_REFERENCE *references, *reference;
+ i4 i;
+
+ scm = &Sc_main_cb->scm;
+
+ stm = NULL;
+
+ /* See if we got this reference before */
+ for (i = 0; i < MAXMONITOR*2; i++)
+ {
+ if (scm->references[i] == NULL)
+ {
+ /* End of the list - reference not found */
+ break;
+
+ } else if (
+ scm->references[i]->object_type == object_type
+ &&
+ scm->references[i]->object_id == object_id
+ &&
+ scm->references[i]->table_id == table_id )
+ {
+
+ /*
+ ** We may have found it.
+ ** Now let's get the current statement
+ ** for more comparisons
+ */
+
+ if (stm == NULL)
+ {
+ stm = scm_get_cur_stmt();
+ }
+
+ /* Still NULL? */
+ if (stm == NULL)
+ {
+ /* Error - return without complaining */
+ return;
+ }
+
+ if (
+ scm->references[i]->query_key == stm->query_key
+ &&
+ STncmp(scm->references[i]->database, stm->database, DB_MAXNAME-1) == 0 )
+ {
+ /*
+ ** We found it.
+ ** We don't need to log it again
+ ** so we just return
+ */
+ return;
+ }
+
+ }
+
}
- scm->qef_time = time;
+ /*
+ ** Log a new reference.
+ ** But we may already have the current statement
+ */
+ if (stm == NULL)
+ {
+ stm = scm_get_cur_stmt();
+ }
+
+ reference = (SCM_REFERENCE*)MEreqmem(0, sizeof(SCM_REFERENCE),TRUE,&status);
+
+ if (status)
+ {
+ /*
+ ** We silently ignore the error.
+ ** A failure in the monitor shouldn't stop query execution
+ */
+ return;
+ }
+
+ reference->object_type = object_type;
+ reference->object_id = object_id;
+ reference->table_id = table_id;
+ reference->query_key = stm->query_key;
+ STncpy(reference->database, stm->database, DB_MAXNAME);
+ reference->database[DB_MAXNAME-1] = '\0';
+
+ /*
+ ** Now let's attach it to the monitor
+ ** But first let's see if we reached the boundary of the array
+ */
+ if (scm->cur_ref_idx >= MAXMONITOR*2)
+ {
+ /*
+ ** Let's wrap around and start overwriting
+ ** the oldest entries in the array
+ */
+ scm->cur_ref_idx = 0;
+
+ }
+
+ /* Second see if we need to remove an old reference from memory */
+ SCM_REFERENCE *old_ref;
+ old_ref = scm->references[scm->cur_ref_idx];
+ if (old_ref != NULL)
+ {
+ char buf[80];
+ MOptrout(0, (PTR)old_ref, sizeof(buf), buf);
+ MOdetach(scm_ref_index_class, buf);
+ MEfree((PTR)old_ref);
+ }
+
+ /* And now attach the new reference to IMA */
+ char buf[80];
+ MOptrout(0, (PTR)reference, sizeof(buf), buf);
+ MOattach(MO_INSTANCE_VAR, scm_ref_index_class, buf, (PTR)reference);
+
+ scm->references[scm->cur_ref_idx] = reference;
+
+ /* Increment the current id */
+ scm->cur_ref_idx++;
+
+ return;
+
+}
+
+/*{
+** Name: scm_log_table - Log a table
+**
+** Description:
+** This functions logs a table referenced by a statement
+**
+** Inputs:
+** table_id the id of the table
+** name the name of the table
+** datapages the number of data pages
+** overflow the number of overflow pages
+** structure the structure of the table
+**
+** Outputs:
+** none.
+**
+** Returns:
+** none.
+**
+** History:
+** 30-Jun-2008 (thial01)
+** created
+*/
+
+VOID
+scm_log_table(
+ i4 table_id,
+ char *name,
+ i4 datapages,
+ i4 overflow,
+ i4 structure )
+{
+ DB_STATUS status;
+ SCM *scm;
+ SCM_TABLE *table, *tables;
+ i4 i;
+ SCD_SCB *scb;
+ char *db_name;
+ scb = scm_get_scb();
+
+ db_name = scb->scb_sscb.sscb_ics.ics_dbname.db_db_name;
+
+ scm = &Sc_main_cb->scm;
+
+ i4 found = -1;
+
+ /* See if we got this table before */
+ for (i = 0; i < MAXMONITOR; i++)
+ {
+ if (scm->tables[i] == NULL)
+ {
+ /* End of the list - table not found */
+ break;
+
+ } else if (
+ scm->tables[i]->table_id == table_id
+ &&
+ STncmp(scm->tables[i]->database, db_name, DB_MAXNAME-1) == 0 )
+ {
+
+ /* We found it */
+ found = i;
+ break;
+ }
+ }
+
+ if (found == -1)
+ {
+
+ table = (SCM_TABLE*)MEreqmem(0, sizeof(SCM_TABLE),TRUE,&status);
+
+ if (status)
+ {
+ /*
+ ** We silently ignore the error.
+ ** A failure in the monitor shouldn't stop query execution
+ */
+ return;
+ }
+
+ table->table_id = table_id;
+ STncpy(table->database, db_name, DB_MAXNAME);
+ STncpy(table->name, name, DB_MAXNAME);
+ table->database[DB_MAXNAME-1] = '\0';
+ table->name[DB_MAXNAME-1] = '\0';
+ table->frequency = 0;
+
+ /*
+ ** Now let's attach it to the monitor
+ ** But first let's see if we reached the boundary of the array
+ */
+ if (scm->cur_tab_idx >= MAXMONITOR)
+ {
+ /*
+ ** Let's wrap around and start overwriting
+ ** the oldest entries in the array
+ */
+ scm->cur_tab_idx = 0;
+
+ }
+
+ /* Second see if we need to remove an old table from memory */
+ SCM_TABLE *old_tab;
+ old_tab = scm->tables[scm->cur_tab_idx];
+ if (old_tab != NULL)
+ {
+ char buf[80];
+ MOptrout(0, (PTR)old_tab, sizeof(buf), buf);
+ MOdetach(scm_tab_index_class, buf);
+ MEfree((PTR)old_tab);
+ }
+
+ /* And now attach the new table to IMA */
+ char buf[80];
+ MOptrout(0, (PTR)table, sizeof(buf), buf);
+ MOattach(MO_INSTANCE_VAR, scm_tab_index_class, buf, (PTR)table);
+
+ scm->tables[scm->cur_tab_idx] = table;
+
+ /* Increment the current id */
+ scm->cur_tab_idx++;
+
+ } else
+ {
+ /* Use the existing instance instead */
+ table = scm->tables[found];
+ }
+
+ /* Update the entry */
+ table->frequency++;
+ table->structure = structure;
+ table->data_pages = datapages;
+ table->overflow_pages = overflow;
+
+ /*
+ ** Now log the reference between this table
+ ** and the current statement
+ */
+ scm_log_reference(SCM_TYPE_TABLE, table_id, 0);
+
+ return;
+
}
+
+/*{
+** Name: scm_log_table_costs - Log table statistics
+**
+** Description:
+** This functions logs estimated and actual table costs
+**
+** Inputs:
+** table_id id of the table
+** est_cpu estimated cpu cost
+** act_cpu actual cpu cost
+** est_dio estimated dio cost
+** act_dio actual dio cost
+** est_tup estimated tuple count
+** act_tup actual tuple count
+**
+** Outputs:
+** none.
+**
+** Returns:
+** none.
+**
+** History:
+** 30-Jun-2008 (thial01)
+** created
+*/
+
+VOID
+scm_log_table_costs(
+ i4 table_id,
+ i4 est_cpu,
+ i4 act_cpu,
+ i4 est_dio,
+ i4 act_dio,
+ i4 est_tup,
+ i4 act_tup )
+{
+
+ SCD_SCB *scb;
+ SCM *scm;
+ char* db_name;
+ i4 i = 0;
+
+ scb = scm_get_scb();
+
+ db_name = scb->scb_sscb.sscb_ics.ics_dbname.db_db_name;
+
+ scm = &Sc_main_cb->scm;
+
+ for (i = 0; i < MAXMONITOR; i++)
+ {
+ if (scm->tables[i] == NULL)
+ {
+ break;
+
+ } else if (
+ scm->tables[i]->table_id == table_id
+ &&
+ STncmp(scm->tables[i]->database, db_name, DB_MAXNAME-1) == 0 )
+ {
+
+ scm->tables[i]->est_cpu = est_cpu;
+ scm->tables[i]->act_cpu = act_cpu;
+ scm->tables[i]->est_dio = est_dio;
+ scm->tables[i]->act_dio = act_dio;
+ scm->tables[i]->est_tup = est_tup;
+ scm->tables[i]->act_tup = act_tup;
+
+ break;
+
+ }
+ }
+
+ return;
+
+}
+
+/*{
+** Name: scm_log_attribute - Log an attribute
+**
+** Description:
+** This functions logs an attribute referenced by a statement
+**
+** Inputs:
+** table_id the id of the table the attribute is in
+** attr_id the id of the attribute
+** name the name of the attribute
+**
+** Outputs:
+** none.
+**
+** Returns:
+** none.
+**
+** History:
+** 02-Jul-2008 (thial01)
+** created
+*/
+
+VOID
+scm_log_attribute(
+ i4 table_id,
+ i4 attr_id,
+ char *name )
+{
+ DB_STATUS status;
+ SCM *scm;
+ SCM_ATTRIBUTE *attribute, *attributes;
+ i4 i;
+ SCD_SCB *scb;
+ char *db_name;
+
+ scb = scm_get_scb();
+
+ db_name = scb->scb_sscb.sscb_ics.ics_dbname.db_db_name;
+
+ scm = &Sc_main_cb->scm;
+
+ i4 found = -1;
+
+ /* See if we got this attribute before */
+ for (i = 0; i < MAXMONITOR; i++)
+ {
+ if (scm->attributes[i] == NULL)
+ {
+ /* End of the list - attribute not found */
+ break;
+
+ } else if (
+ scm->attributes[i]->table_id == table_id
+ &&
+ scm->attributes[i]->attribute_id == attr_id
+ &&
+ STncmp(scm->attributes[i]->database, db_name, DB_MAXNAME-1) == 0 )
+ {
+
+ /* We found it */
+ found = i;
+ break;
+ }
+ }
+
+ if (found == -1)
+ {
+
+ attribute = (SCM_ATTRIBUTE*)MEreqmem(0, sizeof(SCM_ATTRIBUTE),TRUE,&status);
+
+ if (status)
+ {
+ /*
+ ** We silently ignore the error.
+ ** A failure in the monitor shouldn't stop query execution
+ */
+ return;
+ }
+
+ attribute->table_id = table_id;
+ attribute->attribute_id = attr_id;
+ STncpy(attribute->database, db_name, DB_MAXNAME);
+ STncpy(attribute->name, name, DB_MAXNAME);
+ attribute->database[DB_MAXNAME-1] = '\0';
+ attribute->name[DB_MAXNAME-1] = '\0';
+ attribute->frequency = 0;
+
+ /*
+ ** Now let's attach it to the monitor
+ ** But first let's see if we reached the boundary of the array
+ */
+ if (scm->cur_atr_idx >= MAXMONITOR)
+ {
+ /*
+ ** Let's wrap around and start overwriting
+ ** the oldest entries in the array
+ */
+ scm->cur_atr_idx = 0;
+
+ }
+
+ /* Second see if we need to remove an old attribute from memory */
+ SCM_ATTRIBUTE *old_atr;
+ old_atr = scm->attributes[scm->cur_atr_idx];
+ if (old_atr != NULL)
+ {
+ char buf[80];
+ MOptrout(0, (PTR)old_atr, sizeof(buf), buf);
+ MOdetach(scm_atr_index_class, buf);
+ MEfree((PTR)old_atr);
+ }
+
+ /* And now attach the new attribute to IMA */
+ char buf[80];
+ MOptrout(0, (PTR)attribute, sizeof(buf), buf);
+ MOattach(MO_INSTANCE_VAR, scm_atr_index_class, buf, (PTR)attribute);
+
+ scm->attributes[scm->cur_atr_idx] = attribute;
+
+ /* Increment the current id */
+ scm->cur_atr_idx++;
+
+ } else
+ {
+ /* Use the existing instance instead */
+ attribute = scm->attributes[found];
+ }
+
+ /* Update the entry */
+ attribute->frequency++;
+
+ /*
+ ** Now log the reference between this attribute
+ ** and the current statement
+ */
+ scm_log_reference(SCM_TYPE_ATTR, attr_id, table_id);
+
+ return;
+
+}
+
+/*{
+** Name: scm_log_index - Log an index
+**
+** Description:
+** This functions logs an index available for a statement.
+** This index may not actually be used by the optimizer.
+**
+** Inputs:
+** index_id the id of the index table
+** name the name of the index
+** table_id the id of the base table
+** attr_id the id of the indexed attribute
+** datapages the number of data pages
+** overflow the number of overflow pages
+** structure the structure of the table
+**
+** Outputs:
+** none.
+**
+** Returns:
+** none.
+**
+** History:
+** 02-Jul-2008 (thial01)
+** created
+*/
+
+VOID
+scm_log_index(
+ i4 index_id,
+ char *name,
+ i4 table_id,
+ i4 attr_id,
+ i4 datapages,
+ i4 overflow,
+ i4 structure )
+{
+ DB_STATUS status;
+ SCM *scm;
+ SCM_INDEX *index, *indexes;
+ i4 i;
+ SCD_SCB *scb;
+ char *db_name;
+
+ scb = scm_get_scb();
+
+ db_name = scb->scb_sscb.sscb_ics.ics_dbname.db_db_name;
+
+ scm = &Sc_main_cb->scm;
+
+ /* See if we got this index before */
+ for (i = 0; i < MAXMONITOR; i++)
+ {
+ if (scm->indexes[i] == NULL)
+ {
+ /* End of the list - index not found */
+ break;
+
+ } else if (
+ scm->indexes[i]->index_id == index_id
+ &&
+ STncmp(scm->indexes[i]->database, db_name, DB_MAXNAME-1) == 0 )
+ {
+
+ /* We found it so we can return */
+ return;
+ }
+ }
+
+ index = (SCM_INDEX*)MEreqmem(0, sizeof(SCM_INDEX),TRUE,&status);
+
+ if (status)
+ {
+ /*
+ ** We silently ignore the error.
+ ** A failure in the monitor shouldn't stop query execution
+ */
+ return;
+ }
+
+ index->index_id = index_id;
+ index->table_id = table_id;
+ index->attribute_id = attr_id;
+ STncpy(index->database, db_name, DB_MAXNAME);
+ STncpy(index->name, name, DB_MAXNAME);
+ index->database[DB_MAXNAME-1] = '\0';
+ index->name[DB_MAXNAME-1] = '\0';
+ /*
+ ** If this index is never actually used
+ ** this remains at 0 and we should remove
+ ** this unnecessary index
+ */
+ index->frequency = 0;
+
+ /*
+ ** Now let's attach it to the monitor
+ ** But first let's see if we reached the boundary of the array
+ */
+ if (scm->cur_idx_idx >= MAXMONITOR)
+ {
+ /*
+ ** Let's wrap around and start overwriting
+ ** the oldest entries in the array
+ */
+ scm->cur_idx_idx = 0;
+
+ }
+
+ /* Second see if we need to remove an old index from memory */
+ SCM_INDEX *old_idx;
+ old_idx = scm->indexes[scm->cur_idx_idx];
+ if (old_idx != NULL)
+ {
+ char buf[80];
+ MOptrout(0, (PTR)old_idx, sizeof(buf), buf);
+ MOdetach(scm_idx_index_class, buf);
+ MEfree((PTR)old_idx);
+ }
+
+ /* And now attach the new index to IMA */
+ char buf[80];
+ MOptrout(0, (PTR)index, sizeof(buf), buf);
+ MOattach(MO_INSTANCE_VAR, scm_idx_index_class, buf, (PTR)index);
+
+ scm->indexes[scm->cur_idx_idx] = index;
+
+ /* Increment the current id */
+ scm->cur_idx_idx++;
+
+ /*
+ ** We log this index as a reference for the current statement.
+ ** We will see which index was really used by the frequency field.
+ */
+ scm_log_reference(SCM_TYPE_INDEX, index_id, 0);
+
+ return;
+
+}
+
+/*{
+** Name: scm_log_used_index - Log a used index
+**
+** Description:
+** This functions logs when an index was actually used
+** by the optimizer.
+**
+** Inputs:
+** index_id the id of the index table
+**
+** Outputs:
+** none.
+**
+** Returns:
+** none.
+**
+** History:
+** 02-Jul-2008 (thial01)
+** created
+*/
+
+VOID
+scm_log_used_index( i4 index_id )
+{
+ SCM *scm;
+ SCM_INDEX *index, *indexes;
+ i4 i;
+ SCD_SCB *scb;
+ char *db_name;
+
+ scb = scm_get_scb();
+
+ db_name = scb->scb_sscb.sscb_ics.ics_dbname.db_db_name;
+
+ scm = &Sc_main_cb->scm;
+
+ i4 found = -1;
+
+ /* Get the index from the list */
+ for (i = 0; i < MAXMONITOR; i++)
+ {
+ if (scm->indexes[i] == NULL)
+ {
+ /* End of the list - index not found.
+ ** We must return without doing anything
+ */
+ return;
+
+ } else if (
+ scm->indexes[i]->index_id == index_id
+ &&
+ STncmp(scm->indexes[i]->database, db_name, DB_MAXNAME-1) == 0 )
+ {
+
+ /* We found it */
+ scm->indexes[i]->frequency++;
+ return;
+ }
+ }
+
+ return;
+
+}
Modified: branches/advisor/src/back/scf/scs/scsqncr.c
===================================================================
--- branches/advisor/src/back/scf/scs/scsqncr.c 2008-07-02 13:51:12 UTC (rev 137)
+++ branches/advisor/src/back/scf/scs/scsqncr.c 2008-07-03 12:00:03 UTC (rev 138)
@@ -4109,10 +4109,9 @@
else
op_ccb->opf_thandle = qe_ccb->qef_qsf_handle.qso_handle;
- /* Start counting the time we need to process the query */
- TIMER t1, t2;
- TIMER result;
- TMstart(&t1);
+ /* Start counting the time we need to optimize the query */
+ TIMERSTAT opf_timer_start;
+ CSstatistics(&opf_timer_start, 0);
IIEXtry
{
@@ -4127,12 +4126,12 @@
}
IIEXendtry
- TMend(&t1);
+ TIMERSTAT opf_timer_end;
+ CSstatistics(&opf_timer_end, 0);
+
/* Logging how long the query was in opf */
- scm_log_opf_time(t1.timer_value.stat_wc);
+ scm_log_opf_time(&opf_timer_start, &opf_timer_end);
- TMstart(&t2);
-
/* Turn off suboptimization bit */
op_ccb->opf_smask &= ~(OPF_SUBOPTIMIZE | OPF_NOAGGCOMBINE);
cquery->cur_subopt = FALSE;
@@ -4146,10 +4145,6 @@
/* interrupt, it'll be */
/* handled below */
- TMend(&t2);
- /* Logging how long the query was in qef */
- scm_log_qef_time(t2.timer_value.stat_wc);
-
/* Reset this field as OPF likes to trash it! */
((ADF_CB *) scb->scb_sscb.sscb_adscb)->adf_qlang =
scb->scb_sscb.sscb_ics.ics_qlang;
@@ -5816,6 +5811,10 @@
qef_wants_eiqp = 0;
}
+ /* Start counting the time we need to execute the query */
+ TIMERSTAT qef_timer_start;
+ CSstatistics(&qef_timer_start, 0);
+
scb->scb_sscb.sscb_cfac = DB_QEF_ID;
/* Set query access mode to UPDATE */
qe_ccb->qef_qacc = QEF_UPDATE;
@@ -5838,6 +5837,12 @@
status = qef_call(QEQ_QUERY, ( PTR ) qe_ccb);
}
+ TIMERSTAT qef_timer_end;
+ CSstatistics(&qef_timer_end, 0);
+
+ /* Logging how long the query was in qef */
+ scm_log_qef_time(&qef_timer_start, &qef_timer_end);
+
/* Note, this looks slightly premature, but rowprocs can't
** need byref tuples so it's ok.
*/
More information about the svn-commits
mailing list