DROP_STATISTICS(7pg17)

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

✨ DROP STATISTICS ✨

ok so bestie, this is the DROP STATISTICS page from the PostgreSQL 17.11 Documentation, and honestly it's a short one β€” we're literally just yeeting extended statistics objects out of the database πŸ’… let's GO.


πŸŽ€ NAME πŸŽ€

DROP_STATISTICS β€” remove extended statistics. that's it. that's the whole vibe. bye-bye stats object 🫢


🌸 SYNOPSIS 🌸

DROP STATISTICS [ IF EXISTS ] name [, ...] [ CASCADE | RESTRICT ]

look at that syntax. so clean. so iconic. no cap ✨


πŸ¦‹ DESCRIPTION πŸ¦‹

so DROP STATISTICS removes statistics object(s) from the database. like, gone. deleted. no more extended stats for you, bestie 😭

but plot twist β€” not just anyone can do this. only these three qualify:

  • the statistics object's owner
  • the schema owner
  • or a superuser

that's the whole guest list. main character energy only πŸ‘‘


πŸ’– PARAMETERS πŸ’–

  • IF EXISTS β€” do not throw an error if the statistics object does not exist. instead a notice is issued in this case. lowkey polite of it, honestly 🌈
  • name β€” the name of the statistics object to drop. it's optionally schema-qualified, so you can be all schema.object about it if you want πŸŽ€
  • CASCADE, RESTRICT β€” okay so these two key words do not have any effect, because there are literally no dependencies on statistics. so yeah… they're just kind of there. decorative. vibing. πŸ’€ you can type them, nothing will happen, and that's fr fr by design.

πŸ“ EXAMPLES πŸ“

wanna 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 objects, two schemas, zero drama. ate πŸ’…


🧚 COMPATIBILITY 🧚

there is no DROP STATISTICS command in the SQL standard. so this is very much a PostgreSQL exclusive, iykyk ⭐


πŸ”₯ SEE ALSO πŸ”₯

go read those too, bestie, they're the whole friend group 🫢


πŸ’œ reminder bestie: this is from PostgreSQL 17.11, dated 2026 β€” so if you're on a different version, vibe check your own docs first, mwah πŸ’‹

slay, and happy dropping βœ¨πŸ‘‘βœ¨

πŸ“¦ where this page comes from