[svn-commits] r187 - in branches/advisor/src: back/scf/hdr back/scf/scm front/st/vdba
thial01 at ingres.com
thial01 at ingres.com
Tue Aug 12 05:24:40 PDT 2008
Author: thial01
Date: 2008-08-12 05:24:40 -0700 (Tue, 12 Aug 2008)
New Revision: 187
Modified:
branches/advisor/src/back/scf/hdr/scm.h
branches/advisor/src/back/scf/hdr/scmonitor.h
branches/advisor/src/back/scf/scm/scmima.c
branches/advisor/src/back/scf/scm/scmmain.c
branches/advisor/src/back/scf/scm/scmonitor.sc
branches/advisor/src/back/scf/scm/workloaddb.sql
branches/advisor/src/front/st/vdba/makimau.sql
Log:
Rewrite of the monitordb functions to be more efficient... and more correct - see #174
Modified: branches/advisor/src/back/scf/hdr/scm.h
===================================================================
--- branches/advisor/src/back/scf/hdr/scm.h 2008-08-11 15:42:43 UTC (rev 186)
+++ branches/advisor/src/back/scf/hdr/scm.h 2008-08-12 12:24:40 UTC (rev 187)
@@ -25,7 +25,7 @@
** Defines the maximum number of workload entries to log the
** history of statements executed
*/
-#define MAXWORKLOAD 10000
+#define MAXWORKLOAD 1000
/*
** Defines the maximum length of query text to be stored
*/
@@ -56,6 +56,7 @@
u_i4 query_key;
char query_text[MAXQUERYLEN];
i4 frequency;
+ i4 time;
} SCM_STATEMENT;
/*}
@@ -72,6 +73,7 @@
typedef struct _SCM_WORKLOAD
{
char database[DB_MAXNAME];
+ i4 idx;
u_i4 query_key;
u_i4 opf_cpu;
u_i4 opf_dio;
Modified: branches/advisor/src/back/scf/hdr/scmonitor.h
===================================================================
--- branches/advisor/src/back/scf/hdr/scmonitor.h 2008-08-11 15:42:43 UTC (rev 186)
+++ branches/advisor/src/back/scf/hdr/scmonitor.h 2008-08-12 12:24:40 UTC (rev 187)
@@ -16,6 +16,22 @@
** File created
**/
+/* How long do we sleep between wake-ups? */
+#define SLEEP 30000
+/* How often do we wake up until we store data in workload DB? */
+#define ROUNDS 5
+/* How often do we store until we delete old entries from the workload DB? */
+#define DELOLD 5
+/* And how old are the entries we delete (in seconds) */
+#define OLDENTRY 60*60*24*7
+
+/*
+** Define new maximum number of objects to monitor
+** as the monitor may need to fit more than the DBMS
+*/
+#define MAXMON MAXMONITOR * ROUNDS
+#define MAXWKL MAXWORKLOAD * ROUNDS
+
typedef struct _ESQL_SCM_STATEMENT
{
char server[DB_MAXNAME*2];
@@ -23,12 +39,14 @@
u_i4 query_key;
char query_text[MAXQUERYLEN];
u_i4 frequency;
+ i4 time;
} ESQL_SCM_STATEMENT;
typedef struct _ESQL_SCM_WORKLOAD
{
char server[DB_MAXNAME*2];
char database[DB_MAXNAME];
+ u_i4 idx;
u_i4 query_key;
u_i4 opf_cpu;
u_i4 opf_dio;
@@ -120,21 +138,32 @@
typedef struct _ESQL_SCM
{
- ESQL_SCM_STATEMENT statements[MAXMONITOR];
+ ESQL_SCM_STATEMENT statements[MAXMON];
+ i4 cur_stm_idx;
+ i4 maxtime_stm;
- ESQL_SCM_WORKLOAD workload[MAXWORKLOAD];
+ ESQL_SCM_WORKLOAD workload[MAXWKL];
+ i4 cur_wkl_idx;
+ i4 maxtime_wkl;
- ESQL_SCM_TABLE tables[MAXMONITOR];
+ ESQL_SCM_TABLE tables[MAXMON];
+ i4 cur_tab_idx;
+ i4 maxtime_tab;
- ESQL_SCM_ATTRIBUTE attributes[MAXMONITOR];
+ ESQL_SCM_ATTRIBUTE attributes[MAXMON];
+ i4 cur_atr_idx;
+ i4 maxtime_atr;
- ESQL_SCM_INDEX indexes[MAXMONITOR];
+ ESQL_SCM_INDEX indexes[MAXMON];
+ i4 cur_idx_idx;
+ i4 maxtime_idx;
- ESQL_SCM_REFERENCE references[MAXMONITOR*2];
+ ESQL_SCM_REFERENCE references[MAXMON*2];
+ i4 cur_ref_idx;
+ i4 maxtime_ref;
- ESQL_SCM_STATISTICS statistics[MAXMONITOR];
- i4 cur_sts_idx;
-
+ ESQL_SCM_STATISTICS statistics[MAXMON];
+ i4 cur_sts_idx;
} ESQL_SCM;
Modified: branches/advisor/src/back/scf/scm/scmima.c
===================================================================
--- branches/advisor/src/back/scf/scm/scmima.c 2008-08-11 15:42:43 UTC (rev 186)
+++ branches/advisor/src/back/scf/scm/scmima.c 2008-08-12 12:24:40 UTC (rev 187)
@@ -101,6 +101,12 @@
CL_OFFSETOF(SCM_STATEMENT, frequency), MOuintget, MOnoset,
0, MOidata_index
},
+ {
+ MO_CDATA_INDEX, "exp.scf.scm.stm.time",
+ MO_SIZEOF_MEMBER(SCM_STATEMENT, time), MO_READ, scm_stm_index_class,
+ CL_OFFSETOF(SCM_STATEMENT, time), MOuintget, MOnoset,
+ 0, MOidata_index
+ },
{ 0 }
};
@@ -113,6 +119,12 @@
0, MOidata_index
},
{
+ MO_CDATA_INDEX, "exp.scf.scm.wkl.idx",
+ MO_SIZEOF_MEMBER(SCM_WORKLOAD, idx), MO_READ, scm_wkl_index_class,
+ CL_OFFSETOF(SCM_WORKLOAD, idx), MOuintget, MOnoset,
+ 0, MOidata_index
+ },
+ {
MO_CDATA_INDEX, "exp.scf.scm.wkl.query_key",
MO_SIZEOF_MEMBER(SCM_WORKLOAD, query_key), MO_READ, scm_wkl_index_class,
CL_OFFSETOF(SCM_WORKLOAD, query_key), MOuintget, MOnoset,
Modified: branches/advisor/src/back/scf/scm/scmmain.c
===================================================================
--- branches/advisor/src/back/scf/scm/scmmain.c 2008-08-11 15:42:43 UTC (rev 186)
+++ branches/advisor/src/back/scf/scm/scmmain.c 2008-08-12 12:24:40 UTC (rev 187)
@@ -406,12 +406,17 @@
/* How often did we saw this query */
statement->frequency++;
+
+ /* Set the time we saw the query */
+ SYSTIME now;
+ TMnow(&now);
+ statement->time = now.TM_secs;;
/*
** Now create a new workload entry for this statement
** but first let's see if we reached the boundary of the array
*/
- if (scm->cur_wkl_idx >= MAXMONITOR)
+ if (scm->cur_wkl_idx >= MAXWORKLOAD)
{
/*
** Let's wrap around and start overwriting
@@ -445,18 +450,20 @@
scm->workload[scm->cur_wkl_idx] = workload;
}
- scm->cur_wkl_idx++;
+ /*
+ ** We store the current index number to make the entries unique.
+ ** This allows us to make the workload table btree
+ */
+ workload->idx = scm->cur_wkl_idx;
workload->query_key = hashkey;
STncpy(workload->database, db_name, DB_MAXNAME);
workload->database[DB_MAXNAME-1] = '\0';
- /* Set the time we saw the query */
- SYSTIME now;
- TMnow(&now);
workload->time = now.TM_secs;
+
/*
- ** And set the wallclock for this query to -1 so that
+ ** Set the wallclock for this query to -1 so that
** the analyzer knows if this query has completed
*/
workload->wctime = -1;
@@ -468,6 +475,8 @@
*/
scb->scm_current_stmt = (PTR)workload;
+ scm->cur_wkl_idx++;
+
return;
}
@@ -812,7 +821,9 @@
scb = scm_get_scb();
- if (scm_check_analyze(scb))
+ if ( scm_get_cur_stmt() == NULL
+ ||
+ scm_check_analyze(scb) )
{
return;
}
Modified: branches/advisor/src/back/scf/scm/scmonitor.sc
===================================================================
--- branches/advisor/src/back/scf/scm/scmonitor.sc 2008-08-11 15:42:43 UTC (rev 186)
+++ branches/advisor/src/back/scf/scm/scmonitor.sc 2008-08-12 12:24:40 UTC (rev 187)
@@ -71,7 +71,7 @@
**
**/
-#define DEBUG
+// #define DEBUG
/* Global definitions */
exec sql begin declare section;
@@ -81,15 +81,22 @@
exec sql end declare section;
/* How long do we sleep between wake-ups? */
-#define SLEEP 5000
+#define SLEEP 30000
/* How often do we wake up until we store data in workload DB? */
-#define ROUNDS 1
+#define ROUNDS 5
/* How often do we store until we delete old entries from the workload DB? */
#define DELOLD 5
/* And how old are the entries we delete (in seconds) */
#define OLDENTRY 60*60*24*7
+/*
+** Define new maximum number of objects to monitor
+** as the monitor may need to fit more than the DBMS
+*/
+#define MAXMON MAXMONITOR * ROUNDS
+#define MAXWKL MAXWORKLOAD * ROUNDS
+
/*{
**
** Name: get_statements() - read statements from IMA
@@ -101,8 +108,10 @@
** none
**
** Outputs:
+** none
** Returns:
-** none
+** bool false if we need to write to workloaddb
+**
** Exceptions:
**
** History:
@@ -110,7 +119,7 @@
** Created
*/
-VOID
+bool
get_statements( VOID )
{
@@ -118,21 +127,26 @@
SIprintf("get_statements\n");
#endif
+ bool ret = TRUE;
+
exec sql begin declare section;
- ESQL_SCM_STATEMENT statement;
+ ESQL_SCM_STATEMENT statement;
+ i4 maxtime;
exec sql end declare section;
+ maxtime = scm->maxtime_stm;
+
/*
** Get all statements from IMADB for the given db_name
*/
exec sql declare stm cursor for
select * from ima_scm_statements
- where database = :db_name;
+ where database = :db_name
+ and time >= :maxtime
+ order by time;
exec sql open stm for readonly;
- i4 i = 0;
-
for (;;)
{
MEfill(sizeof(ESQL_SCM_STATEMENT), 0, &statement);
@@ -148,13 +162,20 @@
PCexit(FAIL);
}
- scm->statements[i++] = statement;
+ if (scm->cur_stm_idx >= MAXMON)
+ {
+ /* Stop here - we need to write to workloaddb first */
+ ret = FALSE;
+ break;
+ }
+ scm->statements[scm->cur_stm_idx++] = statement;
+
}
exec sql close stm;
- return;
+ return ret;
}
/*{
@@ -188,39 +209,30 @@
i4 i;
exec sql begin declare section;
ESQL_SCM_STATEMENT statement;
- i4 frequency;
+ i4 time;
exec sql end declare section;
- for (i = 0; i < MAXMONITOR; i++)
+ for (i = 0; i < scm->cur_stm_idx; i++)
{
- /*
- ** We cannot check for statement == null here
- ** as it is already allocated.
- ** So use the server member instead
- */
- if (scm->statements[i].server[0] == '\0')
- {
- return;
- }
statement = scm->statements[i];
- frequency = 0;
+ time = 0;
- exec sql select frequency
- into :frequency
+ exec sql select time
+ into :time
from statements
where database = :db_name
and query_key = :statement.query_key;
/*
** Let's see if we saw this before
- ** and the frequency is higher so that
- ** we need to update it or not
+ ** and the timestamp is newer so that
+ ** we need to update or not
*/
- if (frequency > 0)
+ if (time > 0)
{
- if (statement.frequency > frequency)
+ if (statement.time > time)
{
exec sql update statements
set
@@ -240,8 +252,17 @@
SIprintf("Error: %s\n", sqlca.sqlerrm.sqlerrmc);
PCexit(FAIL);
}
+
+ if (statement.time > scm->maxtime_stm)
+ {
+ /* Set the new max timestamp */
+ scm->maxtime_stm = statement.time;
+ }
}
+
+ /* Reset the array pointer */
+ scm->cur_stm_idx = 0;
return;
}
@@ -257,8 +278,10 @@
** none
**
** Outputs:
+** none
** Returns:
-** none
+** bool false if we need to write to workloaddb
+**
** Exceptions:
**
** History:
@@ -266,7 +289,7 @@
** Created
*/
-VOID
+bool
get_workload( VOID )
{
@@ -274,24 +297,31 @@
SIprintf("get_workload\n");
#endif
+ bool ret = TRUE;
+
exec sql begin declare section;
- ESQL_SCM_WORKLOAD workload;
+ ESQL_SCM_WORKLOAD workload;
+ i4 maxtime;
exec sql end declare section;
+ maxtime = scm->maxtime_wkl;
+
/*
- ** Get all workload entries from IMADB for the given db_name
+ ** Get workload entries from IMADB for the given db_name
** but only those that have wallclock > -1
- ** i.e. those that have are done with execution
+ ** i.e. those that have are done with execution.
+ ** And only those we didn't see yet
+ ** i.e. those with time higher than the highest we've seen
*/
exec sql declare wkl cursor for
select * from ima_scm_workload
where database = :db_name
- and wctime > -1;
+ and wctime > -1
+ and time >= :maxtime
+ order by time;
exec sql open wkl for readonly;
- i4 i = 0;
-
for (;;)
{
MEfill(sizeof(ESQL_SCM_WORKLOAD), 0, &workload);
@@ -306,14 +336,21 @@
SIprintf("Error: %s\n", sqlca.sqlerrm.sqlerrmc);
PCexit(FAIL);
}
-
- scm->workload[i++] = workload;
+ if (scm->cur_wkl_idx >= MAXWKL)
+ {
+ /* Stop here - we need to write to workloaddb first */
+ ret = FALSE;
+ break;
+ }
+
+ scm->workload[scm->cur_wkl_idx++] = workload;
+
}
- exec sql close stm;
+ exec sql close wkl;
- return;
+ return ret;
}
/*{
@@ -345,49 +382,48 @@
#endif
i4 i;
+ i4 maxtime = 0;
+ bool log;
+
exec sql begin declare section;
ESQL_SCM_WORKLOAD workload;
- i4 count;
+ i4 rowcount;
exec sql end declare section;
- for (i = 0; i < MAXMONITOR; i++)
+ for (i = 0; i < scm->cur_wkl_idx; i++)
{
- /*
- ** We cannot check for workload == null here
- ** as it is already allocated.
- ** So use the server member instead
- */
- if (scm->workload[i].server[0] == '\0')
- {
- return;
- }
workload = scm->workload[i];
- count = 0;
+ rowcount = 0;
- exec sql select count(*)
- into :count
+ exec sql select count(server)
+ into :rowcount
from workload
- where database = :db_name
- and query_key = :workload.query_key;
-
- /*
- ** Let's see if we saw this before
- */
- if (count == 0)
+ where idx = :workload.idx;
+
+ if (rowcount == 0)
{
exec sql insert into workload
values (:workload);
+
+ if (sqlca.sqlcode != 0)
+ {
+ SIprintf("Error: %s\n", sqlca.sqlerrm.sqlerrmc);
+ PCexit(FAIL);
+ }
}
-
- if (sqlca.sqlcode != 0)
+
+ if (workload.time > scm->maxtime_wkl)
{
- SIprintf("Error: %s\n", sqlca.sqlerrm.sqlerrmc);
- PCexit(FAIL);
+ /* Set the new max timestamp */
+ scm->maxtime_wkl = workload.time;
}
}
+
+ /* Reset the array pointer */
+ scm->cur_wkl_idx = 0;
return;
}
@@ -403,8 +439,10 @@
** none
**
** Outputs:
+** none
** Returns:
-** none
+** bool false if we need to write to workloaddb
+**
** Exceptions:
**
** History:
@@ -412,7 +450,7 @@
** Created
*/
-VOID
+bool
get_tables( VOID )
{
@@ -420,19 +458,24 @@
SIprintf("get_tables\n");
#endif
+ bool ret = TRUE;
+
exec sql begin declare section;
- ESQL_SCM_TABLE table;
+ ESQL_SCM_TABLE table;
+ i4 maxtime;
exec sql end declare section;
+
+ maxtime = scm->maxtime_tab;
/* Get all tables from IMADB for the given db_name */
exec sql declare tab cursor for
select * from ima_scm_tables
- where database = :db_name;
+ where database = :db_name
+ and time >= :maxtime
+ order by time;
exec sql open tab for readonly;
- i4 i = 0;
-
for (;;)
{
@@ -448,14 +491,21 @@
SIprintf("Error: %s\n", sqlca.sqlerrm.sqlerrmc);
PCexit(FAIL);
}
+
+ if (scm->cur_tab_idx >= MAXMON)
+ {
+ /* Stop here - we need to write to workloaddb first */
+ ret = FALSE;
+ break;
+ }
- scm->tables[i++] = table;
+ scm->tables[scm->cur_tab_idx++] = table;
}
exec sql close tab;
- return;
+ return ret;
}
/*{
@@ -492,17 +542,8 @@
i4 time;
exec sql end declare section;
- for (i = 0; i < MAXMONITOR; i++)
+ for (i = 0; i < scm->cur_tab_idx; i++)
{
- /*
- ** We cannot check for table == null here
- ** as it is already allocated.
- ** So use the server member instead
- */
- if (scm->tables[i].server[0] == '\0')
- {
- return;
- }
table = scm->tables[i];
@@ -552,8 +593,17 @@
PCexit(FAIL);
}
+ if (table.time > scm->maxtime_tab)
+ {
+ /* Set the new max timestamp */
+ scm->maxtime_tab = table.time;
+ }
+
}
+ /* Reset the array pointer */
+ scm->cur_tab_idx = 0;
+
return;
}
@@ -568,8 +618,10 @@
** none
**
** Outputs:
+** none
** Returns:
-** none
+** bool false if we need to write to workloaddb
+**
** Exceptions:
**
** History:
@@ -577,7 +629,7 @@
** Created
*/
-VOID
+bool
get_attributes( VOID )
{
@@ -585,19 +637,24 @@
SIprintf("get_attributes\n");
#endif
+ bool ret = TRUE;
+
exec sql begin declare section;
- ESQL_SCM_ATTRIBUTE attribute;
+ ESQL_SCM_ATTRIBUTE attribute;
+ i4 maxtime;
exec sql end declare section;
+
+ maxtime = scm->maxtime_atr;
/* Get all attributes from IMADB for the given db_name */
exec sql declare atr cursor for
select * from ima_scm_attributes
- where database = :db_name;
+ where database = :db_name
+ and time >= :maxtime
+ order by time;
exec sql open atr for readonly;
- i4 i = 0;
-
for (;;)
{
@@ -613,14 +670,21 @@
SIprintf("Error: %s\n", sqlca.sqlerrm.sqlerrmc);
PCexit(FAIL);
}
+
+ if (scm->cur_atr_idx >= MAXMON)
+ {
+ /* Stop here - we need to write to workloaddb first */
+ ret = FALSE;
+ break;
+ }
- scm->attributes[i++] = attribute;
+ scm->attributes[scm->cur_atr_idx++] = attribute;
}
exec sql close atr;
- return;
+ return ret;
}
/*{
@@ -657,17 +721,8 @@
i4 time;
exec sql end declare section;
- for (i = 0; i < MAXMONITOR; i++)
+ for (i = 0; i < scm->cur_atr_idx; i++)
{
- /*
- ** We cannot check for attribute == null here
- ** as it is already allocated.
- ** So use the server member instead
- */
- if (scm->attributes[i].server[0] == '\0')
- {
- return;
- }
attribute = scm->attributes[i];
@@ -712,8 +767,17 @@
PCexit(FAIL);
}
+ if (attribute.time > scm->maxtime_atr)
+ {
+ /* Set the new max timestamp */
+ scm->maxtime_atr = attribute.time;
+ }
+
}
+ /* Reset the array pointer */
+ scm->cur_atr_idx = 0;
+
return;
}
@@ -728,8 +792,10 @@
** none
**
** Outputs:
+** none
** Returns:
-** none
+** bool false if we need to write to workloaddb
+**
** Exceptions:
**
** History:
@@ -737,7 +803,7 @@
** Created
*/
-VOID
+bool
get_indexes( VOID )
{
@@ -745,19 +811,24 @@
SIprintf("get_indexes\n");
#endif
+ bool ret = TRUE;
+
exec sql begin declare section;
- ESQL_SCM_INDEX index;
+ ESQL_SCM_INDEX index;
+ i4 maxtime;
exec sql end declare section;
+ maxtime = scm->maxtime_idx;
+
/* Get all indexes from IMADB for the given db_name */
exec sql declare idx cursor for
select * from ima_scm_indexes
- where database = :db_name;
+ where database = :db_name
+ and time >= :maxtime
+ order by time;
exec sql open idx for readonly;
- i4 i = 0;
-
for (;;)
{
@@ -773,14 +844,21 @@
SIprintf("Error: %s\n", sqlca.sqlerrm.sqlerrmc);
PCexit(FAIL);
}
+
+ if (scm->cur_idx_idx >= MAXMON)
+ {
+ /* Stop here - we need to write to workloaddb first */
+ ret = FALSE;
+ break;
+ }
- scm->indexes[i++] = index;
+ scm->indexes[scm->cur_idx_idx++] = index;
}
exec sql close idx;
- return;
+ return ret;
}
/*{
@@ -817,17 +895,8 @@
i4 time;
exec sql end declare section;
- for (i = 0; i < MAXMONITOR; i++)
+ for (i = 0; i < scm->cur_idx_idx; i++)
{
- /*
- ** We cannot check for index == null here
- ** as it is already allocated.
- ** So use the server member instead
- */
- if (scm->indexes[i].server[0] == '\0')
- {
- return;
- }
index = scm->indexes[i];
@@ -872,8 +941,18 @@
PCexit(FAIL);
}
+ if (index.time > scm->maxtime_idx)
+ {
+ /* Set the new max timestamp */
+ scm->maxtime_idx = index.time;
+ }
+
+
}
+ /* Reset the array pointer */
+ scm->cur_idx_idx = 0;
+
return;
}
@@ -888,8 +967,10 @@
** none
**
** Outputs:
+** none
** Returns:
-** none
+** bool false if we need to write to workloaddb
+**
** Exceptions:
**
** History:
@@ -897,7 +978,7 @@
** Created
*/
-VOID
+bool
get_references( VOID )
{
@@ -905,19 +986,24 @@
SIprintf("get_references\n");
#endif
+ bool ret = TRUE;
+
exec sql begin declare section;
- ESQL_SCM_REFERENCE reference;
+ ESQL_SCM_REFERENCE reference;
+ i4 maxtime;
exec sql end declare section;
+
+ maxtime = scm->maxtime_ref;
/* Get all references from IMADB for the given db_name */
exec sql declare ref cursor for
select * from ima_scm_references
- where database = :db_name;
+ where database = :db_name
+ and time >= :maxtime
+ order by time;
exec sql open ref for readonly;
- i4 i = 0;
-
for (;;)
{
@@ -933,14 +1019,21 @@
SIprintf("Error: %s\n", sqlca.sqlerrm.sqlerrmc);
PCexit(FAIL);
}
+
+ if (scm->cur_ref_idx >= MAXMON*2)
+ {
+ /* Stop here - we need to write to workloaddb first */
+ ret = FALSE;
+ break;
+ }
- scm->references[i++] = reference;
+ scm->references[scm->cur_ref_idx++] = reference;
}
exec sql close ref;
- return;
+ return ret;
}
/*{
@@ -977,17 +1070,8 @@
i4 rowcount;
exec sql end declare section;
- for (i = 0; i < MAXMONITOR; i++)
+ for (i = 0; i < scm->cur_ref_idx; i++)
{
- /*
- ** We cannot check for reference == null here
- ** as it is already allocated.
- ** So use the server member instead
- */
- if (scm->references[i].server[0] == '\0')
- {
- return;
- }
reference = scm->references[i];
@@ -1017,8 +1101,17 @@
PCexit(FAIL);
}
+ if (reference.time > scm->maxtime_ref)
+ {
+ /* Set the new max timestamp */
+ scm->maxtime_ref = reference.time;
+ }
+
}
+ /* Reset the array pointer */
+ scm->cur_ref_idx = 0;
+
return;
}
@@ -1033,8 +1126,10 @@
** none
**
** Outputs:
+** none
** Returns:
-** none
+** bool false if we need to write to workloaddb
+**
** Exceptions:
**
** History:
@@ -1042,7 +1137,7 @@
** Created
*/
-VOID
+bool
get_statistics( VOID )
{
@@ -1050,8 +1145,10 @@
SIprintf("get_statistics\n");
#endif
+ bool ret = TRUE;
+
exec sql begin declare section;
- ESQL_SCM_STATISTICS statistics;
+ ESQL_SCM_STATISTICS statistics;
exec sql end declare section;
MEfill(sizeof(ESQL_SCM_STATISTICS), 0, &statistics);
@@ -1066,10 +1163,16 @@
SIprintf("Error: %s\n", sqlca.sqlerrm.sqlerrmc);
PCexit(FAIL);
}
-
+
scm->statistics[scm->cur_sts_idx++] = statistics;
+
+ if (scm->cur_sts_idx >= MAXMON)
+ {
+ /* We need to write to workloaddb */
+ ret = FALSE;
+ }
- return;
+ return ret;
}
/*{
@@ -1152,6 +1255,7 @@
}
}
+ /* Reset the array pointer */
scm->cur_sts_idx = 0;
SYSTIME now;
@@ -1343,6 +1447,9 @@
i4 round = 0;
i4 delold = 0;
+ /* Clear the SCM structure */
+ MEfill(sizeof(ESQL_SCM), 0, scm);
+
/* Main loop */
while(1)
{
@@ -1353,16 +1460,16 @@
/*
** Get the data from IMA.
- ** Should have been one function but
- ** the esql preprocessor is a bit tricky
+ ** When one call returns false then we
+ ** know that we need to write to workloaddb
*/
- get_statements();
- get_workload();
- get_tables();
- get_attributes();
- get_indexes();
- get_references();
- get_statistics();
+ if (!get_statements()) { round = ROUNDS+1; }
+ if (!get_workload()) { round = ROUNDS+1; }
+ if (!get_tables()) { round = ROUNDS+1; }
+ if (!get_attributes()) { round = ROUNDS+1; }
+ if (!get_indexes()) { round = ROUNDS+1; }
+ if (!get_references()) { round = ROUNDS+1; }
+ if (!get_statistics()) { round = ROUNDS+1; }
if (++round > ROUNDS)
{
Modified: branches/advisor/src/back/scf/scm/workloaddb.sql
===================================================================
--- branches/advisor/src/back/scf/scm/workloaddb.sql 2008-08-11 15:42:43 UTC (rev 186)
+++ branches/advisor/src/back/scf/scm/workloaddb.sql 2008-08-12 12:24:40 UTC (rev 187)
@@ -6,6 +6,7 @@
query_key integer4 not null,
query_text varchar(1000) not null,
frequency integer4,
+ time integer4,
primary key (database, query_key)
)
\p\g
@@ -17,6 +18,7 @@
create table workload (
server varchar(64) not null,
database varchar(32) not null,
+ idx integer4 not null,
query_key integer4 not null,
opf_cpu integer4,
opf_dio integer4,
@@ -26,10 +28,15 @@
est_dio integer4,
pages_touched integer4,
time integer4,
- wctime integer4
+ wctime integer4,
+ primary key (idx)
)
\p\g
+modify workload to btree\p\g
+
+create index workload_time_idx on workload(time) with structure = btree\p\g
+
drop table tables\p\g
create table tables (
Modified: branches/advisor/src/front/st/vdba/makimau.sql
===================================================================
--- branches/advisor/src/front/st/vdba/makimau.sql 2008-08-11 15:42:43 UTC (rev 186)
+++ branches/advisor/src/front/st/vdba/makimau.sql 2008-08-12 12:24:40 UTC (rev 187)
@@ -2067,7 +2067,9 @@
query_text varchar(1000) not null not default
is 'exp.scf.scm.stm.query_text',
frequency integer4 not null not default
- is 'exp.scf.scm.stm.frequency'
+ is 'exp.scf.scm.stm.frequency',
+ time integer4 not null not default
+ is 'exp.scf.scm.stm.time'
)
as import from 'tables'
with dbms = IMA,
@@ -2081,6 +2083,8 @@
server varchar(64) not null not default is 'SERVER',
database varchar(32) not null not default
is 'exp.scf.scm.wkl.database',
+ idx integer4 not null not default
+ is 'exp.scf.scm.wkl.idx',
query_key integer4 not null not default
is 'exp.scf.scm.wkl.query_key',
opf_cpu integer4 not null not default
@@ -2104,8 +2108,8 @@
)
as import from 'tables'
with dbms = IMA,
-structure = sortkeyed,
-key = (server);
+structure = unique sortkeyed,
+key = (server, idx);
\p\g
More information about the svn-commits
mailing list