News for hackers. Stuff that matters.
Re:An unexpected find that freed 20GB of unused index space ... by de6u99er on Monday February 01, 2021 @10:44AM (#25989622)
When I did my Oracle DBA training 15 years ago, I learnt about database reorgs.

It means basically exporting your database (or tables) and importing it again. What happens is that deleted data which doesn't necessarily free up space (Oracle reuses the freed up space sometimes) doesn't get exported.

https://www.iri.com/blog/vldb-operations/database-reorgs-why...

https://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUEST...

Re:An unexpected find that freed 20GB of unused index space ... by brianwawok on Monday February 01, 2021 @10:51AM (#25989672)
A vacuum full basically does this for a table, copying the data from location A to location B, cleaning up junk. I think index rebuilding may take a separate command?
Re:An unexpected find that freed 20GB of unused index space ... by Tostino on Monday February 01, 2021 @10:59AM (#25989742)
Vacuum full does a index rebuild automatically. Since a vacuum full builds an entire new heap table, the old indexs are all pointing to the incorrect locations for all tuples, so it has no choice but to rebuild.
Re:An unexpected find that freed 20GB of unused index space ... by brianwawok on Monday February 01, 2021 @12:16PM (#25990651)
Excellent there you go.

Is there a way to just do the index build part, short of dropping an index and adding it back?

Re:An unexpected find that freed 20GB of unused index space ... by Jedd on Monday February 01, 2021 @05:44PM (#25995155)
This is described about a quarter the way into TFA.

> REINDEX INDEX CONCURRENTLY index_name;

(A vanilla REINDEX will lock the table, preventing writes, while it runs. The CONCURRENT creates a new index, replicates any updates to the original while it does so, and then does an atomic switcheroo at the end.)

Re:An unexpected find that freed 20GB of unused index space ... by jvolkman on Monday February 01, 2021 @12:44PM (#25991033)
I believe pg_repack can do that.
Re:An unexpected find that freed 20GB of unused index space ... by jeffbee on Monday February 01, 2021 @12:01PM (#25990457)
Dumping and reloading databases used to be mandatory for major postgresql updates, which is one of the reasons postgresql wasn't suitable for production workloads until recently and also why it resisted fixing bugs in vacuum, index, and compaction for many years.
Re:An unexpected find that freed 20GB of unused index space ... by AbacusAvenger on Monday February 01, 2021 @12:06PM (#25990524)
Whoah, that's news to me.

I used PostgreSQL fairly recently (a year or so ago?) and ended up abandoning it after I was forced to do the export/import dance through a few version upgrades.

When did that requirement go away?

Re:An unexpected find that freed 20GB of unused index space ... by Uberphallus on Monday February 01, 2021 @12:16PM (#25990650)
Since 9 there's pg_upgrade, personally I never had an issue and it was very fast, so the downtime is in the order of a few minutes, which is ok for my usecase. YMMV.
Re:An unexpected find that freed 20GB of unused index space ... by avereveard on Monday February 01, 2021 @02:23PM (#25992492)
"pg_upgrade does its best to make sure the old and new clusters are binary-compatible, e.g., by checking for compatible compile-time settings, including 32/64-bit binaries. It is important that any external modules are also binary compatible, though this cannot be checked by pg_upgrade."

This makes me very nervous tho, I've at least two exts (trigrams and gists) maybe they work, maybe not, I just prefer the ease of mind of a old fashioned dump.

Re:An unexpected find that freed 20GB of unused index space ... by Uberphallus on Tuesday February 02, 2021 @05:18AM (#25999225)
Don't take my word for it, but I think those extensions aren't considered "external" as they're part of the PGSQL distribution.

It'd be something like nominatim.so, which is external to PGSQL and (AFAIK) has its own format for certain types of data and indexes.

Re:An unexpected find that freed 20GB of unused index space ... by jskrablin on Monday February 01, 2021 @04:46PM (#25994451)
Ever since there's pg_upgrade available. Since 8.4 or so - https://www.percona.com/blog/2019/04/12/fast-upgrade-of-lega...

Dump and reload is ok if you have a small database or can afford hours of downtime... if not, use pg_upgrade.

Re:An unexpected find that freed 20GB of unused index space ... by dialamac on Monday February 01, 2021 @12:10PM (#25990572)
It never did.

The difference is that you can use logical replication since 10 to prevent downtime during upgrade.

Which if you were using it a year ago could have been done.