What is queryband?
Teradata is a diligent RDBMS that runs sometimes millions of SQLs a day. You will see them in the DBQL (DataBase Query Logging area) - if it is switched on - but it's a hard job to know around in that mess of queries. How can I find a specific query? What did that query run by? If I want to analyze or modify something I need to find the source of the execution as exactly as can be.Queryband is a labelling possibility to flag the queries to let their source job/report/etc. be easily found.
Who defines the queryband?
Setting the queryband is usually the responsibility of the query runner:- ETL software or solution that executes it
- OLAP tool that issues it
- Person, who runs it ad-hoc
How to set the queryband?
Technically it is a quite simple stuff: Teradata provides a command to set it:
SET QUERY_BAND = {'<variable1>=<value1>;<variable2>=<value2>;...' / NONE} [UPDATE] for SESSION/TRANSACTION;
, where:
<variable1>=<value1>;
Queryband can consist of arbitrary number of "variable"-"value" pairs. Both are string values. Do not forget to put the semicolon after each variable-value pair!
NONE: clears the queryband
UPDATE: is specified, then those variables that has been previously defined are updated by the new value, others are added with the given value. Empty value string is a valid content and will not remove the variable. Please note that deleting a value is only possible by redefining the queryband without that specific variable.
SESSION/TRANSACTION: what it says...
Where can I check queryband?
The values are reflected in the dbc.SessionfoX.QueryBand and the dbc.DBQLogtbl.QueryBand. The following example shows its content:SET QUERY_BAND='PROJECT=TeraTuningBlog;TASK=QB_example;' for session;
(For the logged in session)
SELECT queryband FROM dbc.sessioninfoX WHERE sessionNo=session;----------------------------------------------------
No comments:
Post a Comment