tdfs4ds.call_phases¶
tdfs4ds.call_phases
¶
History of the framework's own cost per call and phase (0.3.8.0).
FS_CALL_PHASES (optional table, append-only) keeps, for every banded tdfs4ds call, one row per
(call, process, phase): statements, database time, CPU, I/O, spool, skew and rows written, copied
from DBQL by :func:harvest_call_phases (a third, separate INSERT ... SELECT run by
harvest_execution_resources, so a run pays nothing more). Nothing is written by the client.
Reading it¶
FS_V_CALL_PHASES: the facts, plusPHASE_GROUP(work / safety / framework).FS_V_FRAMEWORK_COST_RUN: one row per call and process: the step's framework, safety and work statements and database time, rows written andFIXED_COST_RESIDUAL(the step's framework time minus the process's median): the anomaly signal.FS_V_FRAMEWORK_COST_DAILY: one row per (day, process, phase group), days without a call filled with zeros over the process's active span: a regular series forTD_ARIMA*or anomaly detection.- :func:
framework_costreads them; :func:register_framework_monitoring(opt-in) stores the cost as features of its own data domain.
What the figures are, and are not¶
- The call band carries no process id: a statement has a process only inside an execution
(ingestion). Statements outside it belong to the call; when a call touched exactly one process
they are attributed to it, otherwise
PROCESS_IDis NULL (call level) and the views showCALL_LEVEL. - Rows: DBQL has no row count for
CREATE TABLE ... AS(the staging).ROWS_WRITTENis the feature rows the MERGE / INSERT statements wrote (StmtDMLRowCount): an unchanged re-run writes 0.ROWS_RETURNEDis the rows the SELECTs returned. - A call's number of steps is its number of executions (
CALL_EXECUTIONS, at least 1): aroll_outof 2 processes over 3 dates is 6 steps, of which the call-level statements are shared. DB_ELAPSED_SECis DBQL'sFirstRespTime - StartTimesummed over the statements: the database side only; the round trip is the client's (seetdfs4ds.profile).- A statement's mechanism (
client/procedure/macro) comes from the optional band keyTDFS4DS_MECHANISM; without itclient.
COLUMNS
module-attribute
¶
COLUMNS = ('CALL_ID', 'PROCESS_ID', 'PHASE', 'CALL_KIND', 'MECHANISM', 'PACKAGE_VERSION', 'APP_USER', 'DATA_DOMAIN', 'PROCESS_VIEW', 'RUN_ID', 'VALIDTIME_DATE', 'CALL_START', 'CALL_END', 'CALL_EXECUTIONS', 'N_STATEMENTS', 'N_ERRORS', 'DB_ELAPSED_SEC', 'AMP_CPU_SEC', 'IMPACT_CPU_SEC', 'TOTAL_IO', 'MAX_SPOOL_BYTES', 'CPU_SKEW_PCT', 'IO_SKEW_PCT', 'ROWS_WRITTEN', 'ROWS_RETURNED', 'HARVESTED_AT')
logger_safe
¶
Wrapper around the global logger that only emits logs when
tdfs4ds.DISPLAY_LOGS is True. level is a string like "info", "error", etc.
sql_literal
¶
Escape value for use inside a single-quoted SQL string literal.
For the DBC probes and catalog predicates that compare a name as data
(WHERE DatabaseName = '…'). The caller supplies the surrounding quotes.
run_view_sql
¶
One row per (call, process): the step's cost by group. steps = executions of the call (>= 1).
call_phases_creation
¶
Create FS_CALL_PHASES and its three views when missing. Never raises; a failure is
remembered and not retried (the table is optional).
_statement_base_sql
¶
The DBQL statements of banded calls: one row each, with the phase, the band values and the
measures (the same formulas as profiling.run_profile_sql / followup_resource_usage_sql).
harvest_sql
¶
The INSERT ... SELECT that stores the calls whose DBQL rows are complete and not stored yet.
_bound_days
¶
Days of DBQL to scan: from two days before the last stored call, else everything DBQL holds.
harvest_call_phases
¶
Copy the finished calls from DBQL into FS_CALL_PHASES (in the database, nothing comes to the
client). Never raises: {"ok", "rows", "error", "sql"}.
framework_cost_sql
¶
The SELECT behind :func:framework_cost. Pure.
framework_cost
¶
The framework's own cost, read from FS_CALL_PHASES' views.
level: 'call' (call x process x phase), 'run' (call x process: the step's framework, safety
and work cost and FIXED_COST_RESIDUAL) or 'daily' (day x process x phase group, zero-filled).
Returns a teradataml DataFrame, or a pandas frame with as_pandas=True. Empty until a banded call
has been harvested (DBQL flushes every 10 minutes; harvest_execution_resources(force...)).
write_framework_cost_report
¶
write_framework_cost_report(path=None, days=90, data_domains=None, fmt='html', measure_round_trip=False) -> str
Write the framework cost report (the app's Performance > Framework cost tab) to path and return it.
fmt: 'html' (a standalone page, light and dark) or 'csv' (one row per call and process).
Reads FS_CALL_PHASES only; never changes anything.
monitoring_sql
¶
The two process views of the monitoring: {view_name: (sql, entity_id, features)}. Pure.
register_framework_monitoring
¶
register_framework_monitoring(data_domain='FS_MONITORING', run_now=True, window_days=MONITOR_WINDOW_DAYS)
Store the framework's cost as features (opt-in): two process views over FS_V_FRAMEWORK_COST_DAILY
registered in their own data domain, so history, lineage and time travel come from the store.
FS_MON_FRAMEWORK_BY_PROCESS(entityPROCESS_ID):framework_statements_per_step,framework_sec_per_step,work_sec_per_1k_rows,safety_shareover the last window_days.FS_MON_FRAMEWORK_BY_DOMAIN(entityMONITORED_DOMAIN):domain_framework_share,domain_calls.
Writes only in data_domain (the global tdfs4ds.DATA_DOMAIN is restored). Drive it with
tdfs4ds.run(process_id) daily, or a domain clock. Returns {view_name: process_id}
(None for a registration that was refused: see the log).