VACUUM and re-indexing in PostgreSQL - postgresql

I have automated the VACUUMING and re indexing for my PostgreSQL cluster running on same day.
what should we perform first to get more performance VACUUMING and re indexing?
please advice, thank you

Related

PostgreSQL 9.6 vacuum using 100% CPU

I am running PostgreSQL 9.6 on Centos 7.
The database was migrated from a PostgreSQL 9.4 server that did not have the issue.
With autovacuum on Postgres is using 100% of one core constantly (10% of total CPU). With autovacuum off it does not use any CPU other than when executing queries.
If this expected or normal, or something bad going on? Note it is a very big database, with many schemas/tables.
I tried,
vacuumdb --all -w
and,
ANALYZE VERBOSE;
The "ANALYZE VERBOSE;" made the database run a lot faster, but did not change the CPU usage.

Upgraded RDS postgres from 11.16 to 14.4, CPU has been stuck at 100% for hours while running the huge aggregate queries

We have upgraded our AWS RDS Postgres from 11.16 to 14.4, After that I can see CPU stay around 100% for long hours while running the aggregate Queries.
I'm working with a large database. Most of the main tables have 1 million records. While running these aggregate queries in previous version (11.16) it will give the result without increasing the CPU usage.
Can we use ANALYZE command for optimizing the upgraded database?
Is there any impact when we running this command on database?
Any suggestions for resolving this?

Do we need to have an additional reindex job in place for PostgreSQL when we already have a biweekly pg_repack job?

We already have a pg_repack job running biweekly on our AWS Aurora PostgreSQL Instances. Is it taking care of index fragmentation as well?
If we still need to,
What all indexes should be the candidates of reindexing in PostgreSQL. Do we have any query through which we can list down such indexes?
Thanks

pg_dump does not full copy of db

I have a database db1 which works very slow. It executes hard queries with joins few minutes. I created a copy of that database: db2. Then I created and tuned some indexes and that db2 began to work much faster! After that my goal was to tune db1 working fast as db2. I made copy of db2 (pg_dump -Fc db2 > db2.dump) and restore it to new db1. Then I tested it's speed. But the speed of work not the same! The new db1 much slower (as it was before). What's the problem here? Does pg_dump dumps everything inside db? Data, indexes and so on? Please advice.
After loading,the statictics tables are still empty (they are not part of the dump). You need to run analyze manually.as explained in the postgres manual
Yes pg_dump dump all object definitions, table, view, indexes, type and do on. You have reset the cache and destroy all staistics, so when running the same query in a fresh restore you may encounter bad query times, you can do an ANALYZE to refresh all the stats, but consider that you have now in your cluster db2 + db1 instead of only db1 as before, so the cache is less available for db1, you have to destroy db2 before doing your analyze.

Postgresql 9.2.1, vacuum freeze process stuck while running

In postgresql 9.2.1, i'm running vacuum freeze process in single user mode. suddenly, the vacuuming process got stuck in the half way through (just frozen while vacuuming some transactions).
What would be the reasons for that vacuuming process can stuck in
half way ?
How can i prevent it ?