Prepends 'EXPLAIN ...' to the query respecting the given dialect.
(self, timing: bool, dialect: Dialect = Dialect.MZ)
| 42 | return m.group("name") if m else "anonoymous" |
| 43 | |
| 44 | def explain(self, timing: bool, dialect: Dialect = Dialect.MZ) -> str: |
| 45 | """Prepends 'EXPLAIN ...' to the query respecting the given dialect.""" |
| 46 | |
| 47 | if dialect == Dialect.PG: |
| 48 | if timing: |
| 49 | return "\n".join(["EXPLAIN (ANALYZE, TIMING TRUE)", self.query]) |
| 50 | else: |
| 51 | return "\n".join(["EXPLAIN", self.query]) |
| 52 | else: |
| 53 | if timing: |
| 54 | return "\n".join(["EXPLAIN WITH(timing)", self.query]) |
| 55 | else: |
| 56 | return "\n".join(["EXPLAIN", self.query]) |
| 57 | |
| 58 | |
| 59 | class ExplainOutput: |