Postgres extremely slow after upgrade from Version 10 to 11 Related to this:PostgreSQL extremely slow after upgrade from 9.3 to 9.4
but trying to understand better...

My queries was slow after upgrading to Postgres Version 11.5 from 10.7
I first ran ANALYZE on the DB but still was slow!
so I can VACUUM ANALYZE on the DB, and was still slow...

as a last resort, I am running VACUUM FULL ANALYZE on a table by table basis using psycopg2 with autocommit on (http://initd.org/psycopg/docs/connection.html#connection.autocommit) to be able to run it in psycopg2 

one table is taking hours to do ...
while I wait, I can't help but wonder what went wrong.
The reduction of the query performance was mainly from UPSERT.
The output of pg_upgrade includes this:

...

Upgrade Complete
----------------
Optimizer statistics are not transferred by pg_upgrade so,
once you start the new server, consider running:
    ./analyze_new_cluster.sh

...


We found horrible performance straight after the upgrade until we ran this, lesson learned to read the output :)