classCreateStatistics
final class CreateStatistics
implements Statement
uses Snapshot
Public API: explicitly declared with
@visibility public.A request to create extended statistics on columns or expressions of a table.
Mirrors PostgreSQL's CreateStatsStmt (defnames, stat_types, exprs, relations, if_not_exists). The FROM items are derived as in a query (the server accepts one table); the columns and expressions are derived where they are visible. A single table declared as a view or a sequence is reported (PG-RELATION-KIND-001). Source: https://www.postgresql.org/docs/17/sql-createstatistics.html.
$statement = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('CREATE STATISTICS IF NOT EXISTS s (ndistinct) ON a, (a + b) FROM t');
$statement->toString() // => 'CREATE STATISTICS IF NOT EXISTS s (ndistinct) ON a, (a + b) FROM t'Properties§
public non-empty-list<ColumnKey|ExpressionKey> $keyspublic non-empty-list<Relation> $frompublic list<Name> $kindspublic DottedName|null $namepublic bool $ifNotExists = falseMethods§
public function __construct(
public DottedName|null $name,
list<ColumnKey|ExpressionKey> $keys,
list<Relation> $from,
list<Name> $kinds = [],
public bool $ifNotExists = false,
)Parameters
$name | DottedName|null | The statistics name; required with IF NOT EXISTS |
$keys | list<ColumnKey|ExpressionKey> | The columns and expressions |
$from | list<Relation> | The FROM items |
$kinds | list<Name> | The kinds of statistics; none means all |
$ifNotExists | bool | Whether IF NOT EXISTS is written |
Calls 6
- method-call KeyTerms::checked() line 70
- new KeyTerms line 70
- static-call Check::listOf() line 71
- class-const Relation::class() line 71
- class-const Name::class() line 72
- static-call Check::input() line 73
public function deriveStatement(Derivation $derivation): voidDerives the FROM items, then the columns and expressions where they are visible.
Parameters
$derivation | Derivation |
Calls 11
- method-call StatisticsScope::derive() line 81
- new StatisticsScope line 81
- new RelationKinds line 82
- function-call
countline 83 - method-call RelationKinds::require() line 85
- method-call RelationKinds::declared() line 85
- class-const RelationKind::BaseTable() line 85
- class-const RelationKind::MaterializedView() line 85
- class-const RelationKind::ForeignTable() line 85
- class-const KindRule::StatisticsRelation() line 85
- method-call Derivation::scalar() line 89
public function render(Output $out): voidWrites the statement.
Parameters
$out | Output |
Calls 4
- method-call Output::keyword() line 98
- method-call Output::node() line 102
- method-call Writing::parenthesized() line 104
- new Writing line 104
Test cases 1§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 1
CreateStatisticsTestcalls