Hello,
If tables has a lot of rows with large objects (>1_000_000) that
removed throughout the day, it would be useful to know how many
LOs going to be removed.
First patch - print the number of large objects going to be removed,
second patch - print how many LOs removed in percent.
Can anyone please review.
Please cc, I am not subscribed to the list.
Regards,
Timur
From 8465774c33b200c1a531465acaef85d2d261bb26 Mon Sep 17 00:00:00 2001
From: Timur Birsh <t...@linukz.org>
Date: Wed, 12 Jun 2019 04:13:29 +0000
Subject: [PATCH 1/2] vacuumlo: print the number of large objects going to be
removed
If tables has a lot of rows with large objects (>1_000_000) that
removed throughout the day, it would be useful to know how many
LOs going to be removed.
---
contrib/vacuumlo/vacuumlo.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/contrib/vacuumlo/vacuumlo.c b/contrib/vacuumlo/vacuumlo.c
index 73c06a043e..beade1c9c0 100644
--- a/contrib/vacuumlo/vacuumlo.c
+++ b/contrib/vacuumlo/vacuumlo.c
@@ -64,6 +64,7 @@ vacuumlo(const char *database, const struct _param *param)
PGresult *res,
*res2;
char buf[BUFSIZE];
+ long to_delete = 0;
long matched;
long deleted;
int i;
@@ -276,6 +277,25 @@ vacuumlo(const char *database, const struct _param *param)
}
PQclear(res);
+ if (param->verbose)
+ {
+ snprintf(buf, BUFSIZE, "SELECT count(*) FROM vacuum_l");
+ res = PQexec(conn, buf);
+ if (PQresultStatus(res) != PGRES_TUPLES_OK)
+ {
+ fprintf(stderr, "Failed to get number of large objects "
+ "going to be removed:\n");
+ fprintf(stderr, "%s", PQerrorMessage(conn));
+ PQclear(res);
+ PQfinish(conn);
+ return -1;
+ }
+ to_delete = strtol(PQgetvalue(res, 0, 0), NULL, 10);
+ PQclear(res);
+ fprintf(stdout, "%ld large objects will be removed\n",
+ to_delete);
+ }
+
/*
* Now, those entries remaining in vacuum_l are orphans. Delete 'em.
*
--
2.17.1
From 4be55b5b5e566faad441824910b4e49c6b5f5879 Mon Sep 17 00:00:00 2001
From: Timur Birsh <t...@linukz.org>
Date: Wed, 12 Jun 2019 05:56:44 +0000
Subject: [PATCH 2/2] vacuumlo: print how many LOs removed in percent
---
contrib/vacuumlo/vacuumlo.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/contrib/vacuumlo/vacuumlo.c b/contrib/vacuumlo/vacuumlo.c
index beade1c9c0..5d629264f1 100644
--- a/contrib/vacuumlo/vacuumlo.c
+++ b/contrib/vacuumlo/vacuumlo.c
@@ -359,7 +359,8 @@ vacuumlo(const char *database, const struct _param *param)
if (param->verbose)
{
- fprintf(stdout, "\rRemoving lo %6u ", lo);
+ fprintf(stdout, "\rRemoving lo %6u\t(%3.f%%)", lo,
+ ((float) deleted / (float) to_delete) * 100);
fflush(stdout);
}
--
2.17.1