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.

Creating statisticsdoctest
$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> $keys
public non-empty-list<Relation> $from
public list<Name> $kinds
public DottedName|null $name
public bool $ifNotExists = false

Methods§

public function __construct(
    public DottedName|null $name,
    list<ColumnKey|ExpressionKey> $keys,
    list<Relation> $from,
    list<Name> $kinds = [],
    public bool $ifNotExists = false,
)

Parameters

$nameDottedName|nullThe statistics name; required with IF NOT EXISTS
$keyslist<ColumnKey|ExpressionKey>The columns and expressions
$fromlist<Relation>The FROM items
$kindslist<Name>The kinds of statistics; none means all
$ifNotExistsboolWhether IF NOT EXISTS is written
Calls 6
public function deriveStatement(Derivation $derivation): void

Derives the FROM items, then the columns and expressions where they are visible.

Parameters

$derivationDerivation
Calls 11
public function render(Output $out): void

Writes the statement.

Parameters

$outOutput
Calls 4

Test cases 1§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 1

Relations§

Instantiated in 1
Type declarations 1