169 похожих чатов

Hello experts, Could someone kindly tell me how to run vacuum

inside a plpgsql function? If you have any link please share.
Thank you

10 ответов

19 просмотров

What is the goal, what do you expect to achieve? Because usually autovaacuum solves the problem. Sometimes high traffic tables with lots of updates and deletes need some adjustment. And yes, you can change the settings per table.

Amol-Palav Автор вопроса
Stefanie Janine Stölting
What is the goal, what do you expect to achieve? ...

We have many such tables who have different characteristics and demands wrt vacuuming. Having a centralised and self managed routine will help us to manage it easily rather than adjusting each table individually. The question is do we have any way to run vacuum inside plpgsql?

Amol Palav
We have many such tables who have different charac...

You want to add all those fables automatically to a list and vaccuum them even when it might not be necessary? By select table_name from information_schema.tables where not tabke_name in ('not this one'); ? And you believe that to be better and less intrusive for your application?

Amol-Palav Автор вопроса
Stefanie Janine Stölting
You want to add all those fables automatically to ...

Nope, not at all In fact I want to have a job that will support autovacuum but with manual control instead relying on autovacuum. Also, this manual job will help me to discover application's behaviour and even how each customer is using each functionality/table. With your questions, I'm sensing that there's no way to run vacuum inside plpgsql

Amol Palav
We have many such tables who have different charac...

And no, it is not possible to run vacuum inside functions or procedures. Because that would be inside a transaction. It's documented https://www.postgresql.org/docs/current/sql-vacuum.html under NOTES.

Amol Palav
Ok

But you can get the information about dead tuples from statistics: SELECT relname, n_live_tup, n_dead_tup FROM pg_stat_user_tables;

Amol-Palav Автор вопроса
Stefanie Janine Stölting
But you can get the information about dead tuples ...

That's a cumulative info and these counters get reset when maintenance processes run against those tables. Due to this, I can't discover application's behaviour

Amol Palav
That's a cumulative info and these counters get re...

Together with last_vacuum you can copy the data regularly into your own statistics table.

Amol-Palav Автор вопроса

Похожие вопросы

Обсуждают сегодня

Ещё такой вопрос. Мне необходимо хранить пароль пользователя локально. Для этого планирую использовать ini файл. Это для автозаполнения полей логин и пароль при авторизации. Е...
Евгений
19
Всем привет, написал код ниже, но он выдает сегфолт, в чем причина? #include <stdio.h> #include <stdlib.h> #include <string.h> struct product { char *name; float price; };...
buzz базз
75
База данных не поможет. Шифрование не поможет. Какие там ещё варианты? Накидывайте.
КТ315
20
А как лучше конвертировать физический адрес в виртуальный при маппинге? В случае ядра у меня, например, direct mapping, первые 768МБ я как есть мапплю в higher half, а остальн...
Evg Resh
26
А табстоп это сообщение от окна или от элемента управления?
The Bird of Hermes
18
Hi guys, I'm looking for a good LLM course. Is there any course to learn LLMs in advanced? I'm aiming to use them in my apps, so a perfect course in my openion, is not only a ...
Taha
14
Всем привет. Подскажите, пожалуйста, как вы реализовываете следующий функционал. Допустим есть форма, в которой имеется выпадающий список со значениями. Значения хранятся в БД...
Евгений
7
Хех, данные на форме всегда будут "из прошлого", т.к. перезаполнять поля формы в процессе редактирования пользователем - так себе идея. Пользователь может открыть форму редакт...
Alexander Somov
7
Flutter or React native?
Siddharth Goswami
8
So? Did I win?
Jorge
8
Карта сайта