pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
AW: running vacuumlo periodically?
4+ messages / 2 participants
[nested] [flat]

* AW: running vacuumlo periodically?
@ 2021-01-28 17:03  Zwettler Markus (OIZ) <Markus.Zwettler@zuerich.ch>
  0 siblings, 1 reply; 4+ messages in thread

From: Zwettler Markus (OIZ) @ 2021-01-28 17:03 UTC (permalink / raw)
  To: Laurenz Albe <laurenz.albe@cybertec.at>; pgsql-general

> -----Ursprüngliche Nachricht-----
> Von: Laurenz Albe <laurenz.albe@cybertec.at>
> Gesendet: Donnerstag, 28. Januar 2021 17:39
> An: Zwettler Markus (OIZ) <Markus.Zwettler@zuerich.ch>; pgsql-
> general@postgresql.org
> Betreff: Re: running vacuumlo periodically?
> 
> On Thu, 2021-01-28 at 13:18 +0000, Zwettler Markus (OIZ) wrote:
> > Short question. Is it recommended  - or even best practice – to run vacuumlo
> periodically as a routine maintenance task?
> >
> > We don't do it. I think if this would be recommended it would have been
> implemented as an autotask like autovacuum. No?
> 
> It is recommended to run it regularly if
> - you are using large objects
> - you don't have a trigger in place that deletes large objects that you don't
>   need any more
> 
> Only a small minority of people do that, so it wouldn't make sense to automatically
> run that on all databases.
> 
> Avoid large objects if you can.
> 
> Yours,
> Laurenz Albe
> --
> Cybertec | https://www.cybertec-postgresql.com
[Zwettler Markus (OIZ)] 



We didn't recognize that an application is using large objects and didn't delete them.
Now we found >100G dead large objects within the database. :-(

Is there any _GENERIC_ query which enables monitoring for orphaned objects (dead LO)?

select oid from pg_largeobject_metadata m where not exists
 (select 1 from ANY_EXISTING_TABLE_WITHIN_THE_DATABASE  where m.oid = ANY_COLUMN_CONTAINING_OIDs);

check_postgres.pl doesn't have any generic check for it. :-(


Thanks, Markus





^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: AW: running vacuumlo periodically?
@ 2021-01-29 09:24  Laurenz Albe <laurenz.albe@cybertec.at>
  parent: Zwettler Markus (OIZ) <Markus.Zwettler@zuerich.ch>
  0 siblings, 0 replies; 4+ messages in thread

From: Laurenz Albe @ 2021-01-29 09:24 UTC (permalink / raw)
  To: Zwettler Markus (OIZ) <Markus.Zwettler@zuerich.ch>; pgsql-general

On Thu, 2021-01-28 at 17:03 +0000, Zwettler Markus (OIZ) wrote:
> We didn't recognize that an application is using large objects and didn't delete them.
> Now we found >100G dead large objects within the database. :-(
> 
> Is there any _GENERIC_ query which enables monitoring for orphaned objects (dead LO)?
> 
> select oid from pg_largeobject_metadata m where not exists
>  (select 1 from ANY_EXISTING_TABLE_WITHIN_THE_DATABASE  where m.oid = ANY_COLUMN_CONTAINING_OIDs);
> 
> check_postgres.pl doesn't have any generic check for it. :-(

You'll have to examine the application and see which tables reference the
large objects.  Looking for columns with type "oid" will help.

I recommend that you add an "ON UPDATE OR DELETE" trigger that unlinks
orphaned large objects.

Yours,
Laurenz Albe
-- 
Cybertec | https://www.cybertec-postgresql.com






^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* AW: running vacuumlo periodically
@ 2021-01-29 15:44  Zwettler Markus (OIZ) <Markus.Zwettler@zuerich.ch>
  0 siblings, 1 reply; 4+ messages in thread

From: Zwettler Markus (OIZ) @ 2021-01-29 15:44 UTC (permalink / raw)
  To: Laurenz Albe <laurenz.albe@cybertec.at>; pgsql-general

I run "vacuumlo" in batches (-l) which worked well.

I found table "pg_catalog.pg_largeobjects" to be massively bloated afterwards.

I tried "vacuum full pg_catalog.pg_largeobjects" but run out of diskspace (although having 250G diskspace free; database size = 400G).


Question: 
Will "vacuum full pg_catalog.pg_largeobjects" need less diskspace when "maintenance_work_mem" is increased?




> -----Ursprüngliche Nachricht-----
> Von: Zwettler Markus (OIZ) <Markus.Zwettler@zuerich.ch>
> Gesendet: Donnerstag, 28. Januar 2021 18:04
> An: Laurenz Albe <laurenz.albe@cybertec.at>; pgsql-general@postgresql.org
> Betreff: AW: running vacuumlo periodically?
> 
> > -----Ursprüngliche Nachricht-----
> > Von: Laurenz Albe <laurenz.albe@cybertec.at>
> > Gesendet: Donnerstag, 28. Januar 2021 17:39
> > An: Zwettler Markus (OIZ) <Markus.Zwettler@zuerich.ch>; pgsql-
> > general@postgresql.org
> > Betreff: Re: running vacuumlo periodically?
> >
> > On Thu, 2021-01-28 at 13:18 +0000, Zwettler Markus (OIZ) wrote:
> > > Short question. Is it recommended  - or even best practice – to run
> > > vacuumlo
> > periodically as a routine maintenance task?
> > >
> > > We don't do it. I think if this would be recommended it would have
> > > been
> > implemented as an autotask like autovacuum. No?
> >
> > It is recommended to run it regularly if
> > - you are using large objects
> > - you don't have a trigger in place that deletes large objects that you don't
> >   need any more
> >
> > Only a small minority of people do that, so it wouldn't make sense to
> > automatically run that on all databases.
> >
> > Avoid large objects if you can.
> >
> > Yours,
> > Laurenz Albe
> > --
> > Cybertec | https://www.cybertec-postgresql.com
> [Zwettler Markus (OIZ)]
> 
> 
> 
> We didn't recognize that an application is using large objects and didn't delete
> them.
> Now we found >100G dead large objects within the database. :-(
> 
> Is there any _GENERIC_ query which enables monitoring for orphaned objects
> (dead LO)?
> 
> select oid from pg_largeobject_metadata m where not exists  (select 1 from
> ANY_EXISTING_TABLE_WITHIN_THE_DATABASE  where m.oid =
> ANY_COLUMN_CONTAINING_OIDs);
> 
> check_postgres.pl doesn't have any generic check for it. :-(
> 
> 
> Thanks, Markus
> 
> 



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: AW: running vacuumlo periodically
@ 2021-01-29 19:12  Laurenz Albe <laurenz.albe@cybertec.at>
  parent: Zwettler Markus (OIZ) <Markus.Zwettler@zuerich.ch>
  0 siblings, 0 replies; 4+ messages in thread

From: Laurenz Albe @ 2021-01-29 19:12 UTC (permalink / raw)
  To: Zwettler Markus (OIZ) <Markus.Zwettler@zuerich.ch>; pgsql-general

On Fri, 2021-01-29 at 15:44 +0000, Zwettler Markus (OIZ) wrote:
> I run "vacuumlo" in batches (-l) which worked well.
> 
> I found table "pg_catalog.pg_largeobjects" to be massively bloated afterwards.

Sure, that deletes entries from that table.

> I tried "vacuum full pg_catalog.pg_largeobjects" but run out of diskspace (although having 250G diskspace free; database size = 400G).
> 
> Question:
> Will "vacuum full pg_catalog.pg_largeobjects" need less diskspace when "maintenance_work_mem" is increased?

No, it won't.  It will just be faster.
That sounds like your database consists almost exclusively of large objects...

Yours,
Laurenz Albe
-- 
Cybertec | https://www.cybertec-postgresql.com






^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2021-01-29 19:12 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-01-28 17:03 AW: running vacuumlo periodically? Zwettler Markus (OIZ) <Markus.Zwettler@zuerich.ch>
2021-01-29 09:24 ` Laurenz Albe <laurenz.albe@cybertec.at>
2021-01-29 15:44 AW: running vacuumlo periodically Zwettler Markus (OIZ) <Markus.Zwettler@zuerich.ch>
2021-01-29 19:12 ` Re: AW: running vacuumlo periodically Laurenz Albe <laurenz.albe@cybertec.at>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox