[svn-commits] r163 - in branches/advisor/src: back/opf/opj back/opf/ops back/opf/opv back/scf/hdr back/scf/scf back/scf/scm back/scf/scs front/st/vdba
thial01 at ingres.com
thial01 at ingres.com
Thu Jul 17 07:59:12 PDT 2008
Author: thial01
Date: 2008-07-17 07:59:11 -0700 (Thu, 17 Jul 2008)
New Revision: 163
Modified:
branches/advisor/src/back/opf/opj/opjjoinop.c
branches/advisor/src/back/opf/ops/opsseq.c
branches/advisor/src/back/opf/opv/opvparser.c
branches/advisor/src/back/scf/hdr/scm.h
branches/advisor/src/back/scf/hdr/scs.h
branches/advisor/src/back/scf/scf/scfcall.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
branches/advisor/src/front/st/vdba/makimau.sql
Log:
Adding new trace point and struct for analyzer - see #174
Modified: branches/advisor/src/back/opf/opj/opjjoinop.c
===================================================================
--- branches/advisor/src/back/opf/opj/opjjoinop.c 2008-07-17 02:06:27 UTC (rev 162)
+++ branches/advisor/src/back/opf/opj/opjjoinop.c 2008-07-17 14:59:11 UTC (rev 163)
@@ -6125,11 +6125,25 @@
/* Check if this is an index */
if (rel->rdr_rel->tbl_id.db_tab_index > 0)
{
- scm_log_used_index(
+
+ /*
+ ** Check if this is a virtual index.
+ ** Then we know the design analzer is running
+ */
+ if (rel->rdr_rel->tbl_status_mask & DMT_VIRT_INDEX) {
+
+ /* This is a virtual index */
+ scm_log_virt_index(rel->rdr_rel->tbl_name.db_tab_name);
+
+ } else
+ {
+ /* This is a normal index - log it */
+ scm_log_used_index(
rel->rdr_rel->tbl_id.db_tab_index,
rel->rdr_rel->tbl_storage_type,
rel->rdr_rel->tbl_dpage_count,
rel->rdr_rel->tbl_opage_count );
+ }
}
}
Modified: branches/advisor/src/back/opf/ops/opsseq.c
===================================================================
--- branches/advisor/src/back/opf/ops/opsseq.c 2008-07-17 02:06:27 UTC (rev 162)
+++ branches/advisor/src/back/opf/ops/opsseq.c 2008-07-17 14:59:11 UTC (rev 163)
@@ -1262,6 +1262,7 @@
&&
DB_SUCCESS_MACRO(status)
) || global.ops_gmask & OPS_TPROCS /* don't ex. tprocs yet */
+ || scm_check_analyze( NULL ) /* No execution when design analyzer runs */
)
{ /* report a user error indicating trace flag set so query cannot
** be processed */
Modified: branches/advisor/src/back/opf/opv/opvparser.c
===================================================================
--- branches/advisor/src/back/opf/opv/opvparser.c 2008-07-17 02:06:27 UTC (rev 162)
+++ branches/advisor/src/back/opf/opv/opvparser.c 2008-07-17 14:59:11 UTC (rev 163)
@@ -568,7 +568,7 @@
if (grvp->opv_relation->rdr_rel->tbl_status_mask & DMT_VIRT_INDEX)
{
/* we are going to use a virtual index ... */
- if (!opt_strace(global->ops_cb, OPT_F032_NOEXECUTE)) {
+ if (!scm_check_analyze(NULL)) {
gbase->opv_grv[gvar] = NULL; /* deallocate
** variable if index cannot
** be found */
Modified: branches/advisor/src/back/scf/hdr/scm.h
===================================================================
--- branches/advisor/src/back/scf/hdr/scm.h 2008-07-17 02:06:27 UTC (rev 162)
+++ branches/advisor/src/back/scf/hdr/scm.h 2008-07-17 14:59:11 UTC (rev 163)
@@ -32,6 +32,7 @@
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_ana_index_class[] = "exp.scf.scm.ana.index";
/*}
** Name: SCM_STATEMENTS - Structure to hold statement data for monitoring
@@ -169,6 +170,33 @@
} SCM_REFERENCE;
/*}
+** Name: SCM_ANALYZE - Structure to hold analyzer data
+**
+** Description:
+** This structure contains data about the current statement
+** when the design analyzer is running.
+**
+** History:
+** 17-Jul-2008 (thial01)
+** Structur created
+*/
+typedef struct _SCM_ANALYZE
+{
+ /*
+ ** This struct will only have a single instance in IMA.
+ ** No support for multiple analyzer runs at the same time.
+ */
+
+ u_i4 cpu;
+ u_i4 dio;
+ u_i4 pages_touched;
+
+ /* This will contain a list of all virtual indexes used in the QEP */
+ char vindexes[MAXQUERYLEN];
+
+} SCM_ANALYZE;
+
+/*}
** Name: SCM - Main Structur to hold monitor data
**
** Description:
@@ -200,5 +228,7 @@
*/
SCM_REFERENCE *references[MAXMONITOR*2];
i4 cur_ref_idx; /* The position in the array */
-
+
+ SCM_ANALYZE analyze;
+
} SCM;
Modified: branches/advisor/src/back/scf/hdr/scs.h
===================================================================
--- branches/advisor/src/back/scf/hdr/scs.h 2008-07-17 02:06:27 UTC (rev 162)
+++ branches/advisor/src/back/scf/hdr/scs.h 2008-07-17 14:59:11 UTC (rev 163)
@@ -1438,6 +1438,7 @@
#define SCS_TALERT 4 /* Trace sce operations */
#define SCS_TNOTIFY 5 /* Trace event notifications */
#define SCS_TASTATE 6 /* Trace alert state changes */
+#define SCS_ANALYZE 7 /* Added for design analyzer */
i4 sscb_terminating; /* session is terminating */
/* Alert processing control information */
Modified: branches/advisor/src/back/scf/scf/scfcall.c
===================================================================
--- branches/advisor/src/back/scf/scf/scfcall.c 2008-07-17 02:06:27 UTC (rev 162)
+++ branches/advisor/src/back/scf/scf/scfcall.c 2008-07-17 14:59:11 UTC (rev 163)
@@ -800,6 +800,7 @@
case SCS_TEVLOG:
case SCS_TALERT:
case SCS_TNOTIFY:
+ case SCS_ANALYZE:
CSget_scb((CS_SCB **)&scb);
if (trace_cb->db_trswitch == DB_TR_ON)
{
Modified: branches/advisor/src/back/scf/scm/scmima.c
===================================================================
--- branches/advisor/src/back/scf/scm/scmima.c 2008-07-17 02:06:27 UTC (rev 162)
+++ branches/advisor/src/back/scf/scm/scmima.c 2008-07-17 14:59:11 UTC (rev 163)
@@ -418,6 +418,35 @@
{ 0 }
};
+static MO_CLASS_DEF scf_scm_ana_classes[] =
+{
+ {
+ 0, "exp.scf.scm.ana.cpu",
+ MO_SIZEOF_MEMBER(SCM_ANALYZE, cpu), MO_READ, 0,
+ CL_OFFSETOF(SCM_ANALYZE, cpu), MOuintget, MOnoset,
+ 0, MOcdata_index
+ },
+ {
+ 0, "exp.scf.scm.ana.dio",
+ MO_SIZEOF_MEMBER(SCM_ANALYZE, dio), MO_READ, 0,
+ CL_OFFSETOF(SCM_ANALYZE, dio), MOuintget, MOnoset,
+ 0, MOcdata_index
+ },
+ {
+ 0, "exp.scf.scm.ana.pages_touched",
+ MO_SIZEOF_MEMBER(SCM_ANALYZE, pages_touched), MO_READ, 0,
+ CL_OFFSETOF(SCM_ANALYZE, pages_touched), MOuintget, MOnoset,
+ 0, MOcdata_index
+ },
+ {
+ 0, "exp.scf.scm.ana.vindexes",
+ MO_SIZEOF_MEMBER(SCM_ANALYZE, vindexes), MO_READ, 0,
+ CL_OFFSETOF(SCM_ANALYZE, vindexes), MOstrget, MOnoset,
+ 0, MOcdata_index
+ },
+ { 0 }
+};
+
/*{
** Name: scm_mo_init - Init the SCM MO classes
**
@@ -442,11 +471,23 @@
scm_mo_init( VOID )
{
- // Make the MO classes known to MO
+ i4 i;
+ for( i = 0; scf_scm_ana_classes[i].classid != NULL; i++ ) {
+ scf_scm_ana_classes[i].cdata = (PTR)&Sc_main_cb->scm.analyze;
+ }
+
+ /* Make the MO classes known to MO */
MOclassdef(MAXI2, scf_scm_stm_classes);
MOclassdef(MAXI2, scf_scm_tab_classes);
MOclassdef(MAXI2, scf_scm_atr_classes);
MOclassdef(MAXI2, scf_scm_idx_classes);
MOclassdef(MAXI2, scf_scm_ref_classes);
+ MOclassdef(MAXI2, scf_scm_ana_classes);
+
+ /* Attach the singelton analyzer struct at server startup */
+/* char buf[80];
+ MOptrout(0, (PTR)&Sc_main_cb->scm.analyze, sizeof(buf), buf);
+ MOattach(MO_INSTANCE_VAR, scm_ana_index_class, buf, (PTR)&Sc_main_cb->scm.analyze);
+ */
}
Modified: branches/advisor/src/back/scf/scm/scmmain.c
===================================================================
--- branches/advisor/src/back/scf/scm/scmmain.c 2008-07-17 02:06:27 UTC (rev 162)
+++ branches/advisor/src/back/scf/scm/scmmain.c 2008-07-17 14:59:11 UTC (rev 163)
@@ -150,6 +150,39 @@
}
/*{
+** Name: scm_check_analyze - Check if we are in analyse phase
+**
+** Description:
+** This functions returns the state of trace point SC999
+** to see if the design analyzer is currently running
+**
+** Inputs:
+** scb session control block if available
+**
+** Outputs:
+** none.
+**
+** Returns:
+** state true if set, false if not
+**
+** History:
+** 17-Jul-2008 (thial01)
+** created
+*/
+
+bool
+scm_check_analyze( SCD_SCB *scb )
+{
+ /* We didn't get the scb, so let's find it */
+ if (scb == NULL) {
+ scb = scm_get_scb();
+ }
+
+ return ult_check_macro(&scb->scb_sscb.sscb_trace, SCS_ANALYZE, 0, 0);
+
+}
+
+/*{
** Name: scm_stmt_lookup - Search for a statement
**
** Description:
@@ -225,6 +258,11 @@
scb = scm_get_scb();
+ if (scm_check_analyze(scb))
+ {
+ return NULL;
+ }
+
db_name = scb->scb_sscb.sscb_ics.ics_dbname.db_db_name;
key = scb->scm_current_stmt;
@@ -268,6 +306,17 @@
scb = scm_get_scb();
+ if (scm_check_analyze(scb))
+ {
+ /*
+ ** The analyzer is running.
+ ** Don't log anything - just clear the list
+ ** of virtual indexes from the last statement
+ */
+ Sc_main_cb->scm.analyze.vindexes[0] = '\0';
+ return;
+ }
+
scm = &Sc_main_cb->scm;
/* Plain text of the current query */
@@ -384,20 +433,19 @@
TIMERSTAT *end )
{
- SCM_STATEMENT *scm;
+ SCM_STATEMENT *stm;
/* Get the struct of the current statement */
- scm = scm_get_cur_stmt();
+ stm = scm_get_cur_stmt();
- if (scm == NULL)
+ if (stm == NULL)
{
return;
}
- scm->opf_cpu =
+ stm->opf_cpu =
end->stat_cpu - start->stat_cpu;
-
- scm->opf_dio =
+ stm->opf_dio =
end->stat_dio - start->stat_dio;
return;
@@ -431,19 +479,19 @@
TIMERSTAT *end )
{
- SCM_STATEMENT *scm;
+ SCM_STATEMENT *stm;
/* Get the struct of the current statement */
- scm = scm_get_cur_stmt();
+ stm = scm_get_cur_stmt();
- if (scm == NULL)
+ if (stm == NULL)
{
return;
}
- scm->qef_cpu =
+ stm->qef_cpu =
end->stat_cpu - start->stat_cpu;
- scm->qef_cpu =
+ stm->qef_cpu =
end->stat_dio - start->stat_dio;
return;
@@ -479,19 +527,38 @@
i4 touched )
{
- SCM_STATEMENT *scm;
+ if (scm_check_analyze( NULL ))
+ {
+ /*
+ ** The analyzer is running.
+ ** Instead of logging this as normal
+ ** write the values to SCM_ANALYZE
+ */
+ SCM *scm;
+
+ scm = &Sc_main_cb->scm;
+
+ scm->analyze.cpu = cpu;
+ scm->analyze.dio = dio;
+ scm->analyze.pages_touched = touched;
+
+ /* and return */
+ return;
+ }
+ SCM_STATEMENT *stm;
+
/* Get the struct of the current statement */
- scm = scm_get_cur_stmt();
+ stm = scm_get_cur_stmt();
- if (scm == NULL)
+ if (stm == NULL)
{
return;
}
- scm->est_cpu = cpu;
- scm->est_dio = dio;
- scm->pages_touched = touched;
+ stm->est_cpu = cpu;
+ stm->est_dio = dio;
+ stm->pages_touched = touched;
return;
@@ -694,6 +761,11 @@
scb = scm_get_scb();
+ if (scm_check_analyze(scb))
+ {
+ return;
+ }
+
db_name = scb->scb_sscb.sscb_ics.ics_dbname.db_db_name;
scm = &Sc_main_cb->scm;
@@ -845,6 +917,11 @@
scb = scm_get_scb();
+ if (scm_check_analyze(scb))
+ {
+ return;
+ }
+
db_name = scb->scb_sscb.sscb_ics.ics_dbname.db_db_name;
scm = &Sc_main_cb->scm;
@@ -914,6 +991,11 @@
scb = scm_get_scb();
+ if (scm_check_analyze(scb))
+ {
+ return;
+ }
+
db_name = scb->scb_sscb.sscb_ics.ics_dbname.db_db_name;
scm = &Sc_main_cb->scm;
@@ -1057,6 +1139,11 @@
scb = scm_get_scb();
+ if (scm_check_analyze(scb))
+ {
+ return;
+ }
+
db_name = scb->scb_sscb.sscb_ics.ics_dbname.db_db_name;
scm = &Sc_main_cb->scm;
@@ -1130,6 +1217,11 @@
scb = scm_get_scb();
+ if (scm_check_analyze(scb))
+ {
+ return;
+ }
+
db_name = scb->scb_sscb.sscb_ics.ics_dbname.db_db_name;
scm = &Sc_main_cb->scm;
@@ -1262,6 +1354,11 @@
scb = scm_get_scb();
+ if (scm_check_analyze(scb))
+ {
+ return;
+ }
+
db_name = scb->scb_sscb.sscb_ics.ics_dbname.db_db_name;
scm = &Sc_main_cb->scm;
@@ -1302,3 +1399,58 @@
return;
}
+
+/*{
+** Name: scm_log_virt_index - Log a virtual index
+**
+** Description:
+** This functions logs when a virtual index was used
+**
+** Inputs:
+** name name of the index
+**
+** Outputs:
+** none.
+**
+** Returns:
+** none.
+**
+** History:
+** 17-Jul-2008 (thial01)
+** created
+*/
+
+VOID
+scm_log_virt_index( char *name )
+{
+ SCM *scm;
+ i4 len1, len2;
+
+ scm = &Sc_main_cb->scm;
+
+ /*
+ ** We concatenate the index names into one string
+ ** with whitespaces in between.
+ ** The design analyzer will handle it later.
+ */
+
+ /* Trim whitespaces */
+ len1 = STtrmnwhite(name, DB_MAXNAME);
+
+ /* But leave one space to split the names */
+ name[len1] = ' ';
+ name[len1+1] = '\0';
+
+ len2 = STlength(scm->analyze.vindexes);
+ if (len2 > MAXQUERYLEN)
+ {
+ /* String too large */
+ return;
+ }
+
+ STncat(scm->analyze.vindexes, name, DB_MAXNAME);
+
+ return;
+
+}
+
Modified: branches/advisor/src/back/scf/scs/scsqncr.c
===================================================================
--- branches/advisor/src/back/scf/scs/scsqncr.c 2008-07-17 02:06:27 UTC (rev 162)
+++ branches/advisor/src/back/scf/scs/scsqncr.c 2008-07-17 14:59:11 UTC (rev 163)
@@ -2547,6 +2547,10 @@
bool retry_fetch = FALSE;
DMC_CB *dmc;
bool on_user_error = FALSE;
+ TIMERSTAT opf_timer_start;
+ TIMERSTAT opf_timer_end;
+ TIMERSTAT qef_timer_start;
+ TIMERSTAT qef_timer_end;
/*
** qef_wants_ruleqp and qef_psf_alias are used to handle procedure
@@ -4126,12 +4130,14 @@
}
IIEXendtry
- TIMERSTAT opf_timer_end;
CSstatistics(&opf_timer_end, 0);
/* Logging how long the query was in opf */
scm_log_opf_time(&opf_timer_start, &opf_timer_end);
+ /* Start counting the time we need to execute the query */
+ CSstatistics(&qef_timer_start, 0);
+
/* Turn off suboptimization bit */
op_ccb->opf_smask &= ~(OPF_SUBOPTIMIZE | OPF_NOAGGCOMBINE);
cquery->cur_subopt = FALSE;
@@ -5811,10 +5817,6 @@
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;
@@ -5837,7 +5839,6 @@
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 */
Modified: branches/advisor/src/front/st/vdba/makimau.sql
===================================================================
--- branches/advisor/src/front/st/vdba/makimau.sql 2008-07-17 02:06:27 UTC (rev 162)
+++ branches/advisor/src/front/st/vdba/makimau.sql 2008-07-17 14:59:11 UTC (rev 163)
@@ -2486,3 +2486,22 @@
key = (server);
\p\g
+drop table ima_scm_analyze\p\g
+
+register table ima_scm_analyze (
+ server varchar(64) not null not default is 'SERVER',
+ cpu integer4 not null not default
+ is 'exp.scf.scm.ana.cpu',
+ dio integer4 not null not default
+ is 'exp.scf.scm.ana.dio',
+ pages_touchedcpu integer4 not null not default
+ is 'exp.scf.scm.ana.pages_touched',
+ vindexes varchar(1000) not null not default
+ is 'exp.scf.scm.ana.vindexes'
+)
+as import from 'tables'
+with dbms = IMA,
+structure = sortkeyed,
+key = (server);
+\p\g
+
More information about the svn-commits
mailing list