An API for manipulating 'EXPLAIN ... PLAN FOR' results.
| 57 | |
| 58 | |
| 59 | class ExplainOutput: |
| 60 | """An API for manipulating 'EXPLAIN ... PLAN FOR' results.""" |
| 61 | |
| 62 | def __init__(self, output: str) -> None: |
| 63 | self.output = output |
| 64 | |
| 65 | def __str__(self) -> str: |
| 66 | return self.output |
| 67 | |
| 68 | def optimization_time(self) -> np.timedelta64 | None: |
| 69 | """Optionally, returns the optimization_time time for an 'EXPLAIN' output.""" |
| 70 | p = r"(Optimization time|Planning Time)\: (?P<time>[0-9]+(\.[0-9]+)?\s?\S+)" |
| 71 | m = re.search(p, self.output, re.MULTILINE) |
| 72 | return util.duration_to_timedelta(m["time"]) if m else None |
| 73 | |
| 74 | |
| 75 | class Database: |