0

After upgrading the Postgres Server from Version 15 to Version 17 running on RHEL 9, few of the SQLs changed the plan and running pretty slow. I am basically an Oracle DBA and thinking to perform the follow, but want to know what analyze option are best to calculate the stats.

  1. Gather Statistics
  2. Rebuilding the Indexes

Beside above 2 options, if you have any further recommendations that would be highly appreciated.

2
  • Did you do in place upgrade? Commented Jan 11 at 19:33
  • Yes Sir, It was in place upgrade. Commented Jan 14 at 18:32

1 Answer 1

3

Read instructions in the release notes for every major version you traversed. There is always a chapter with essential notes. In your case:

Migration to Version 16

Migration to Version 17

The rest of the release notes may be of interest, too.

You already mentioned "gathering statistics". Make sure to run a global ANALYZE in the database, since statistics for the optimizer are not transferred to the new version by pg_upgrade.
As privileged user connected to the database in question:

ANALYZE;

Or with vacuumdb from the shell - one of:

vacuumdb [connection-option...] --analyze-only
vacuumdb [connection-option...] --analyze

Rebuilding indexes is not necessary unless one of these chapter explicitly instructs to do so. (But if your indexes are bloated, REINDEX won't hurt.)

3
  • Thanks a lot Erwin. Let me try and will get back to you. Commented Jan 14 at 18:33
  • Hi Erwin, Can you please let me know how to run the global Analyze the database? Commented Jan 14 at 18:54
  • @NaveedIftikhar: I added details to the answer. Commented Jan 14 at 20:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.