pgadmin4/web
Michal Charemza 83ade5dcc2
Update the query that fetches roles to be faster with many roles.
This changes the query that fetches roles from using the
pg_catalog.shobj_description function to using an explicit join on
pg_catalog.pg_shdescription. In my specific case, in a production system with
over 20k roles, this reduces the query time down from 8 minutes(!) down to
~40ms. Just in case it was a locking issue, I did use pg_activity to
investigate locks, and nothing was being blocked during the 8 minutes.

This fixes a problem that exists only for certain users, and specifically in my
case where the user that runs the query is themselves a member (directly and
indirectly) of a high number of roles. Running the existing query as a user
that has a low number of roles (and specifically, the master user in an AWS RDS
database), the existing query is fairly performant.

My best explanation as to the performance difference comes from the definition
of shobj_description
2a8a00674e/src/backend/catalog/system_functions.sql (L303-L312).
Each time it's called it runs a query against pg_shdescription and pg_class,
and so in my case runs 20k times, compared to the equivalent of once when doing
the explicit join on pg_shdescription. It should also be noted that in my case
pg_class is quite big - currently about 500k rows (although it has grown to ~5
million in the past, but that was borderline a mistake).

See https://github.com/pgadmin-org/pgadmin4/pull/8457#issue-2853052114 for
EXPLAIN ANALYZE results of the existing query and the updated query.
2025-02-17 17:20:28 +05:30
..
migrations Python v3.8 does not support parenthesized context expressions. 2025-02-06 14:42:29 +05:30
pgacloud Copyright updated for 2025 2025-01-01 11:26:42 +05:30
pgadmin Update the query that fetches roles to be faster with many roles. 2025-02-17 17:20:28 +05:30
regression Fix the following SonarQube issues: 2025-02-13 11:56:10 +05:30
.editorconfig
.eslintrc.js Copyright updated for 2025 2025-01-01 11:26:42 +05:30
.yarnrc.yml Revert yarnrc.yml and yarn.lock 2024-01-24 18:55:32 +05:30
babel.cfg Update message catalog. 2022-04-01 17:22:16 +05:30
babel.config.json Significant changes to use ReactJS extensively. 2023-10-23 17:43:17 +05:30
branding.py Copyright updated for 2025 2025-01-01 11:26:42 +05:30
config.py 1) Added missing GLOBALLY_DELIVERABLE config parameter in the config.py from the last commit. 2025-02-07 13:36:11 +05:30
jest.config.js Fixed jest test cases failing due to an update of react-resize-detector package. 2024-12-30 17:22:07 +05:30
package.json 1) Updated Javascript and Python dependencies. 2025-02-07 11:52:08 +05:30
pgAdmin4.py Copyright updated for 2025 2025-01-01 11:26:42 +05:30
pgAdmin4.wsgi Copyright updated for 2025 2025-01-01 11:26:42 +05:30
setup.py Copyright updated for 2025 2025-01-01 11:26:42 +05:30
version.py 1) Fixed an issue where the server shows disconnected on the Welcome page, even after the password was provided. 2025-02-03 14:26:57 +05:30
webpack.config.js Copyright updated for 2025 2025-01-01 11:26:42 +05:30
webpack.shim.js Copyright updated for 2025 2025-01-01 11:26:42 +05:30
yarn.lock 1) Updated Javascript and Python dependencies. 2025-02-07 11:52:08 +05:30