public inbox for [email protected]  
help / color / mirror / Atom feed
Re: Disk is filling up with large files. How can I clean?
3+ messages / 3 participants
[nested] [flat]

* Re: Disk is filling up with large files. How can I clean?
@ 2024-10-09 09:52 Torsten Förtsch <[email protected]>
  2024-10-09 13:02 ` Re: Disk is filling up with large files. How can I clean? Philip Semanchuk <[email protected]>
  0 siblings, 1 reply; 3+ messages in thread

From: Torsten Förtsch @ 2024-10-09 09:52 UTC (permalink / raw)
  To: Mikael Petterson <[email protected]>; +Cc: [email protected] <[email protected]>

Filenames like 16665, 16665.1, 16665.2 etc all represent the same table (or
similar). The number 16665 is called the file node.

To get a list of file nodes for a specific database you can run:

SELECT oid::regclass::text, relfilenode FROM pg_class;

The /16384/ in the path represents the database. To decipher that you can
run:

SELECT datname, oid FROM pg_database;

Once you have all that information, you know which database to connect to
and which tables are big. Then you can DROP/DELETE/TRUNCATE or so.

Useful functions in that context are pg_relation_size(), pg_table_size(),
pg_total_relation_size() and some more. Check out the manual for more
information.

Example:
SELECT oid::regclass::text, relfilenode, pg_relation_size(oid) as size FROM
pg_class ORDER BY size DESC;


On Wed, Oct 9, 2024 at 10:10 AM Mikael Petterson <
[email protected]> wrote:

> Hi,
>
> I find our disk is filling up.
>
> sudo find /var/lib -type f -size +100M -exec ls -lh {} \; | awk '{ print
> $9 ": " $5 }'
> /var/lib/rpm/Packages: 278M
> /var/lib/pgsql/12/data/base/16384/16583: 392M
> /var/lib/pgsql/12/data/base/16384/16586: 1.0G
> /var/lib/pgsql/12/data/base/16384/16588: 173M
> /var/lib/pgsql/12/data/base/16384/16633: 106M
> /var/lib/pgsql/12/data/base/16384/16644: 179M
> /var/lib/pgsql/12/data/base/16384/16659: 1.0G
> /var/lib/pgsql/12/data/base/16384/16662: 438M
> /var/lib/pgsql/12/data/base/16384/16665: 1.0G
> /var/lib/pgsql/12/data/base/16384/16667: 1.0G
> /var/lib/pgsql/12/data/base/16384/16668: 1.0G
> /var/lib/pgsql/12/data/base/16384/16780: 466M
> /var/lib/pgsql/12/data/base/16384/16786: 182M
> /var/lib/pgsql/12/data/base/16384/16788: 163M
> /var/lib/pgsql/12/data/base/16384/16789: 315M
> /var/lib/pgsql/12/data/base/16384/16790: 126M
> /var/lib/pgsql/12/data/base/16384/16665.2: 403M
> /var/lib/pgsql/12/data/base/16384/16586.7: 1.0G
> /var/lib/pgsql/12/data/base/16384/16586.6: 1.0G
> /var/lib/pgsql/12/data/base/16384/16586.9: 1.0G
> /var/lib/pgsql/12/data/base/16384/16586.8: 1.0G
> /var/lib/pgsql/12/data/base/16384/16659.6: 1.0G
> /var/lib/pgsql/12/data/base/16384/16659.4: 1.0G
> /var/lib/pgsql/12/data/base/16384/16659.5: 1.0G
> /var/lib/pgsql/12/data/base/16384/16668.3: 586M
> /var/lib/pgsql/12/data/base/16384/16586.10: 458M
> /var/lib/pgsql/12/data/base/16384/16659.1: 1.0G
> /var/lib/pgsql/12/data/base/16384/16586.2: 1.0G
> /var/lib/pgsql/12/data/base/16384/16659.2: 1.0G
> /var/lib/pgsql/12/data/base/16384/16668.1: 1.0G
> /var/lib/pgsql/12/data/base/16384/16586.3: 1.0G
> /var/lib/pgsql/12/data/base/16384/16659.3: 1.0G
> /var/lib/pgsql/12/data/base/16384/16586.4: 1.0G
> /var/lib/pgsql/12/data/base/16384/16665.1: 1.0G
> /var/lib/pgsql/12/data/base/16384/16586.5: 1.0G
> /var/lib/pgsql/12/data/base/16384/16586.1: 1.0G
> /var/lib/pgsql/12/data/base/16384/16668.2: 1.0G
> /var/lib/pgsql/12/data/base/16384/16667.1: 741M
> /var/lib/pgsql/12/data/base/16384/4652676: 502M
> /var/lib/pgsql/12/data/base/16384/4652688: 155M
>
> How can I clean up?
>
> What can I do to clean up. We are using pgsql 12.
>
> Br,
>
> //Mikael
>
>
>
>
>
>


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

* Re: Disk is filling up with large files. How can I clean?
  2024-10-09 09:52 Re: Disk is filling up with large files. How can I clean? Torsten Förtsch <[email protected]>
@ 2024-10-09 13:02 ` Philip Semanchuk <[email protected]>
  2024-10-09 14:29   ` Re: Disk is filling up with large files. How can I clean? Ron Johnson <[email protected]>
  0 siblings, 1 reply; 3+ messages in thread

From: Philip Semanchuk @ 2024-10-09 13:02 UTC (permalink / raw)
  To: Torsten Förtsch <[email protected]>; +Cc: Mikael Petterson <[email protected]>; [email protected] <[email protected]>



> On Oct 9, 2024, at 5:52 AM, Torsten Förtsch <[email protected]> wrote:
> 
> Filenames like 16665, 16665.1, 16665.2 etc all represent the same table (or similar). The number 16665 is called the file node.
> 
> To get a list of file nodes for a specific database you can run:
> 
> SELECT oid::regclass::text, relfilenode FROM pg_class;
> 
> The /16384/ in the path represents the database. To decipher that you can run:
> 
> SELECT datname, oid FROM pg_database;
> 
> Once you have all that information, you know which database to connect to and which tables are big. Then you can DROP/DELETE/TRUNCATE or so.

Mikael, if you’re unaware of VACUUM FULL (as opposed to just VACUUM), you should read about that too.

Hope that helps,
Philip





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

* Re: Disk is filling up with large files. How can I clean?
  2024-10-09 09:52 Re: Disk is filling up with large files. How can I clean? Torsten Förtsch <[email protected]>
  2024-10-09 13:02 ` Re: Disk is filling up with large files. How can I clean? Philip Semanchuk <[email protected]>
@ 2024-10-09 14:29   ` Ron Johnson <[email protected]>
  0 siblings, 0 replies; 3+ messages in thread

From: Ron Johnson @ 2024-10-09 14:29 UTC (permalink / raw)
  To: [email protected] <[email protected]>

On Wed, Oct 9, 2024 at 9:02 AM Philip Semanchuk <
[email protected]> wrote:

>
> > On Oct 9, 2024, at 5:52 AM, Torsten Förtsch <[email protected]>
> wrote:
> >
> > Filenames like 16665, 16665.1, 16665.2 etc all represent the same table
> (or similar). The number 16665 is called the file node.
> >
> > To get a list of file nodes for a specific database you can run:
> >
> > SELECT oid::regclass::text, relfilenode FROM pg_class;
> >
> > The /16384/ in the path represents the database. To decipher that you
> can run:
> >
> > SELECT datname, oid FROM pg_database;
> >
> > Once you have all that information, you know which database to connect
> to and which tables are big. Then you can DROP/DELETE/TRUNCATE or so.
>
> Mikael, if you’re unaware of VACUUM FULL (as opposed to just VACUUM), you
> should read about that too.
>

VACUUM FULL with an almost-full disk probably isn't the wisest idea.

-- 
Death to <Redacted>, and butter sauce.
Don't boil me, I'm still alive.
<Redacted> crustacean!


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


end of thread, other threads:[~2024-10-09 14:29 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-10-09 09:52 Re: Disk is filling up with large files. How can I clean? Torsten Förtsch <[email protected]>
2024-10-09 13:02 ` Philip Semanchuk <[email protected]>
2024-10-09 14:29   ` Ron Johnson <[email protected]>

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