STATISTICS

ADD STATISTICS defines multi-column statistics for an existing table. Run ANALYZE to collect them.

DROP STATISTICS removes the multi-column statistics with the specified name.

Statistics types and column requirements are described in CREATE TABLE ... STATISTICS. An ALTER TABLE statement can include several of these actions along with other table changes.

Examples

Add two multi-column sketches and run ANALYZE:

ALTER TABLE orders
    ADD STATISTICS amount_category ON (amount, category) WITH (COUNT_MIN_SKETCH),
    ADD STATISTICS amount_time ON (amount, created_at) WITH (COUNT_MIN_SKETCH);

ANALYZE orders;

Remove the multi-column statistics named amount_category:

ALTER TABLE orders DROP STATISTICS amount_category;
Previous
Next