DROP_STATISTICS(7pg15)
π DROP_STATISTICS π
Hey bestie, welcome to the DROP_STATISTICS page β that's the one from the PostgreSQL 15.19 Documentation, and yes she's short and sweet. Sit down, hydrate, and let's remove some extended statistics together π«Ά
πΈ NAME πΈ
DROP_STATISTICS β remove extended statistics β¨
π¦ SYNOPSIS π¦
DROP STATISTICS [ IF EXISTS ] name [, ...] [ CASCADE | RESTRICT ]
π DESCRIPTION π
So DROP STATISTICS removes statistics object(s) from the database. That's it, that's the whole vibe. It's giving clean slate π
But okay, gatekeeping time: only the statistics object's owner, the schema owner, or a superuser can drop a statistics object. So if you're not one of those, no cap, it's not happening π
β¨ PARAMETERS β¨
IF EXISTSβ do not throw an error if the statistics object does not exist. A notice is issued in this case. Basically "if she's not there, don't make it weird" πnameβ the name (optionally schema-qualified) of the statistics object to drop. Yes you can qualify it, go off πCASCADE,RESTRICTβ these key words do not have any effect, since there are no dependencies on statistics. Literally they're just standing there, existing, contributing nothing π (they're in the synopsis though, so we keep them, iykyk)
π₯ EXAMPLES π₯
To destroy two statistics objects in different schemas, without failing if they don't exist:
DROP STATISTICS IF EXISTS
accounting.users_uid_creation,
public.grants_user_role;
Two different schemas, one command, zero drama. We love a multi-schema moment π
π COMPATIBILITY π
There is no DROP STATISTICS command in the SQL standard. Periodt. She's a PostgreSQL original π
π SEE ALSO π
ALTER STATISTICS(ALTER_STATISTICS(7))CREATE STATISTICS(CREATE_STATISTICS(7))
And that's the whole page, bestie β you ate that π
Friendly reminder of the whole plot: DROP STATISTICS removes extended statistics, and only the owner, schema owner, or superuser can do it.
β Sign-off time β β this little gem is from PostgreSQL 15.19, dated 2026, and it's the DROP STATISTICS(7) page. Bye, love you, go drop some stats responsibly π§π
π¦ where this page comes from
- opensuse-leap 16.0: postgresql15 15.19-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql15 15.19-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql15 15.19-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql15 15.19-160000.1.1 Β· PostgreSQL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms