tdfs4ds.utils.explain_cost¶
tdfs4ds.utils.explain_cost
¶
What a query will cost, read from its Teradata EXPLAIN text, before running it.
explain_cost(text) (pure) reads the optimizer's own estimates:
- the estimated time of each step ("The estimated time for this step is 21 minutes and 58 seconds") and the total when the plan states one;
- the size of each spool ("estimated with low confidence to be 2,526,469,696 rows (1,073,749,620,800 bytes)");
- product joins and all-rows scans.
Lines are wrapped anywhere (a number can start on the next line), so the text is flattened first. A plan of trivial steps states no time at all: that reads as 0.
assess_explain(text, max_seconds, max_spool_bytes) adds the verdict. Step
times are summed, which over-counts steps run in parallel: the gate errs on the
cautious side. The estimates are the optimizer's (often "low confidence"), never
a measurement.
_DURATION
module-attribute
¶
_STEP_TIME
module-attribute
¶
_TOTAL_TIME
module-attribute
¶
_SPOOL
module-attribute
¶
_SPOOL = compile('estimated(?: with (\\w+) confidence)? to be ([\\d,]+) rows?\\s*\\(\\s*([\\d,]+) bytes\\s*\\)', IGNORECASE)
_OVERFLOW
module-attribute
¶
assess_explain
¶
explain_cost plus ok and the reasons it is not. Pure.