DROP_STATISTICS(7pg18)

๐Ÿ“ฆ version 18.6, in opensuse-leap 16.0

๐Ÿ’… 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.mystats is valid, and so is just mystats. iykyk ๐Ÿงš
  • CASCADE
  • RESTRICT โ€” 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 โญ


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