HP Neoview Release 2.5 Software User Manual

Page 63

Advertising
background image

Queries within the Past 24 Hours, Grouped by Data Source

This example indicates how many queries within the 24-hour period were associated with each
data source.

SELECT datasource, COUNT(*) AS NUM_OF_QUERIES
FROM NEO.HP_METRICS.QUERY_STATS_VW2
WHERE EXEC_START_LCT_TS <= CURRENT
AND EXEC_START_LCT_TS >= CURRENT - INTERVAL '1' DAY
AND QUERY_STATUS = 'COMPLETED'
GROUP BY datasource
ORDER BY datasource
FOR READ UNCOMMITTED ACCESS;

Queries within the Past 24 Hours, Grouped by Client Name and Including Average
and Maximum Elapsed Time

SELECT client_name,
COUNT(*) AS num_of_queries,
AVG(query_elapsed_time)/1000 AS avg_qry_elapsed_msec,
MAX(query_elapsed_time)/1000 AS max_qry_elapsed_msec
FROM NEO.HP_METRICS.QUERY_STATS_VW2
WHERE EXEC_START_LCT_TS <= CURRENT
AND EXEC_START_LCT_TS >= CURRENT - INTERVAL '1' DAY
AND QUERY_STATUS = 'COMPLETED'
GROUP BY client_name
ORDER BY client_name
FOR READ UNCOMMITTED ACCESS;

Formatting Techniques to Enhance Readability of Query Output

Often the typical data in a column is much narrower than the maximum defined column size.
For example, the SESSION_ID column is defined as CHARACTER(108), and the DATASOURCE
column is defined as CHARACTER(128); actual values in those columns are usually much shorter.
Many query tools support automatic adjustment of column size for viewing results, but in some
cases, it is necessary to adjust the size of the columns returned from the query to improve
readability of the results.

Neoview SQL supports several string manipulation functions. Among these, the LEFT function
is useful for simple column size reduction. In addition to string functions, use of CAST is
sometimes helpful for modifying the appearance or size of numeric fields.

For example, the following query run from NCI produces results that can be difficult to read:

select [first 10]
datasource,
client_name,

Formatting Techniques to Enhance Readability of Query Output

63

Advertising