beautypg.com

HP Neoview Release 2.4 Software User Manual

Page 71

background image

ORDER BY datasource
FOR READ UNCOMMITTED ACCESS;

NUM_OF_QUERIES

DATASOURCE

51

NEO0101_JOM

44

TDM_Default_DataSource

162

neodb

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

SELECT client_id,
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.ODBC_QUERY_STATS_V2
WHERE QUERY_START_DATETIME <= CURRENT
AND QUERY_START_DATETIME >= CURRENT - INTERVAL '1' DAY
AND STATEMENT_STATE = 'COMPLETE'
GROUP BY client_id
ORDER BY client_id
FOR READ UNCOMMITTED ACCESS;

MAX_QRY_ELAPSED_TIME

AVG_QRY_ELAPSED_MSEC

NUM_OF_QUERIES

CLIENT_ID

32750

17330

16

EXPTC082205

728870

20340

51

ORDROBERTSC-P2

2070

260

162

ORDHROTHGAR-P2

5646470

316730

28

ordbantam-p2

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 produces results that can be difficult to read:

select [first 10]
datasource,
client_id,
count(*) as query_count
from NEO.HP_METRICS.ODBC_QUERY_STATS_V1
where statement_status = 'START'
group by datasource, client_id
order by datasource, client_id;

DATASOURCE
CLIENT_ID QUERY_COUNT
--------------------------------------------------------------------------------------------------------------------------------
--------------- --------------------
RIBE_FIN
NWESTABX-DC76C 1
RR
FENSTERM-DC76C 6593

Formatting Techniques to Enhance Readability of Query Output

71