Hi @Azeem, Muhammad,
Welcome to the Microsoft Q&A Platform! Thank you for asking your question here.
If you are still facing the slowdown in executing queries as a non-azure_pg_admin user, then please follow the below mentioned troubleshooting steps:
1.Query Plan Caching and Role-Based Optimization: PostgreSQL generates cached query plans for certain roles, which might differ based on the user's privileges. Queries run by the azure_pg_admin role often benefit from optimized plans that may not automatically refresh for other roles.
To test if plan caching affects your query, you can use Explicitly analyze the affected tables by running ANALYZE table_name; for each relevant table. This forces PostgreSQL to update statistics, which can improve query planning for non-admin roles.
2.Permissions and Statistics Collection: PostgreSQL can sometimes have different performance behaviour based on roles due to permissions impacting the execution plan. Ensure that statistics for table contents are available and fresh:
VACUUM ANALYZE table_name;
Running VACUUM ANALYZE as a non-admin user may help update statistics for that user context and may improve performance for subsequent queries.
3.Index Rebuilding Impact: Rebuilding indexes should improve performance, but occasionally, it can invalidate certain cached query plans for non-admin roles. To address this:
Reindex non-primary indexes if not done during the rebuild, as fragmented indexes can impact performance.
REINDEX TABLE table_name;
4.Role Privileges and Execution Paths: In PostgreSQL, the azure_pg_admin role may use different execution paths, often more privileged and optimized, while regular roles may experience slower paths, especially if permissions are restrictive.
Consider granting temporary heightened permissions to the non-admin role to determine if it improves performance:
GRANT azure_pg_admin TO non_admin_user;
If performance improves with elevated permissions, the issue may relate to role-specific query planning.
5.Adjust Configuration Parameters (if possible): Some configuration parameters may also affect query performance, especially after major maintenance tasks like FULL VACUUM. For example:
shared_buffers and work_mem settings are essential for query performance.
You can adjust session-specific parameters for non-admin roles to increase memory usage on a per-query basis:
SET work_mem = '64MB'; -- or adjust as appropriate
6.Monitoring and Slow Query Logging: Enable slow query logging in Azure PostgreSQL to understand what specific operations are causing delays for the non-admin roles.
Use the Azure Query Performance Insights feature to gain visibility into query execution and identify bottlenecks for non-admin roles.Bottom of Form
Please refer the below mentioned link.
https://learn.microsoft.com/en-us/azure/postgresql/flexible-server/how-to-create-users
I hope, This response will address your query and helped you to overcome on your challenges.
If this answers your query, do click Accept Answer and Yes for was this answer helpful. And, if you have any further query do let us know.