DROP_STATISTICS(7pg18)
๐ DROP STATISTICS ๐
okay bestie, welcome to DROP_STATISTICS(7) โ that's the PostgreSQL 18.6 documentation page, and she's a short one but she's important, so let's get into it โจ
๐ธ NAME ๐ธ
DROP_STATISTICS โ remove extended statistics ๐๏ธโจ
๐ SYNOPSIS ๐
DROP STATISTICS [ IF EXISTS ] name [, ...] [ CASCADE | RESTRICT ]
that's it. that's the whole vibe. short, sweet, devastating ๐
๐ฆ DESCRIPTION ๐ฆ
so, DROP STATISTICS removes statistics object(s) from the database. like, gone gone. poof ๐ซถ
but ngl there's a gatekeeper, and the gatekeeper is permissions. Only these three people can drop a statistics object:
- the statistics object's owner
- the schema owner
- a superuser
that's the list. no plus-ones. periodt ๐
โจ PARAMETERS โจ
IF EXISTSโ do not throw an error if the statistics object does not exist. a notice is issued in this case. so instead of a whole dramatic meltdown, you just get a lil "hey, that wasn't there btw" ๐nameโ the name (optionally schema-qualified) of the statistics object to drop. so like,myschema.mystatsis valid, and so is justmystats. iykyk ๐งCASCADERESTRICTโ okay so these two key words do not have any effect, since there are no dependencies on statistics. they're literally just there vibing. main character energy with zero plot relevance ๐
๐ EXAMPLES ๐
want to destroy two statistics objects in different schemas, without failing if they don't exist? say less:
DROP STATISTICS IF EXISTS
accounting.users_uid_creation,
public.grants_user_role;
two schemas, one command, zero tears. slay ๐ฅ
๐ COMPATIBILITY ๐
there is no DROP STATISTICS command in the SQL standard. so if you're out here trying to be standards-compliant about it... girl, there's nothing to comply with ๐
โญ SEE ALSO โญ
ALTER STATISTICS(ALTER_STATISTICS(7))CREATE STATISTICS(CREATE_STATISTICS(7))
and that's the whole page, bestie!! this one came to you from PostgreSQL 18.6, dated 2026 โ love her, respect her, drop your stats responsibly ๐๐๐ฆ
๐ฆ where this page comes from
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms