DROP_STATISTICS(7pg15)

πŸ“¦ version 15.19, in opensuse-leap 16.0

πŸ’… 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 πŸ‘‘


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