Postgres Notes: Difference between revisions
From Federal Burro of Information
Jump to navigationJump to search
(Created page with "Wide out out good for seeing and example of FEW records: \x select * from users limit 1; == An App user == Adding a secure , least priviledges user for you app, no root....") |
No edit summary |
||
Line 23: | Line 23: | ||
== RDS Gochas == | == RDS Gochas == | ||
Grant the master user to the role you want to | Grant the master user to the role you want to grant others ( RDS only ) | ||
https://stackoverflow.com/questions/26684643/error-must-be-member-of-role-when-creating-schema-in-postgresql | https://stackoverflow.com/questions/26684643/error-must-be-member-of-role-when-creating-schema-in-postgresql | ||
== per table cache hit ratios == | |||
<pre> | |||
SELECT | |||
relname as table , | |||
heap_blks_read as heap_read, | |||
heap_blks_hit as heap_hit, | |||
to_char( ( heap_blks_hit::decimal / ( heap_blks_hit::decimal + heap_blks_read::decimal ) ) * 100 , '99.99' ) | |||
FROM | |||
pg_statio_user_tables | |||
WHERE | |||
heap_blks_hit + heap_blks_read > 0 | |||
AND relid > 10000 | |||
ORDER BY relname; | |||
</pre> |
Revision as of 18:16, 17 October 2018
Wide out out good for seeing and example of FEW records:
\x select * from users limit 1;
An App user
Adding a secure , least priviledges user for you app, no root.
GRANT USAGE ON SCHEMA public TO myuser; -- more schemas? GRANT SELECT ON ALL TABLES IN SCHEMA public TO myuser;
This ensure taht all subsequent tables are accessable by that user ( role ):
ALTER DEFAULT PRIVILEGES FOR ROLE mycreating_user IN SCHEMA public GRANT SELECT ON TABLES TO myuser;
ref: https://dba.stackexchange.com/questions/91953/grant-access-to-all-tables-of-a-database
full treatment: https://stackoverflow.com/questions/41537825/restricted-postgresql-permissions-for-web-app/47955583#47955583
RDS Gochas
Grant the master user to the role you want to grant others ( RDS only )
per table cache hit ratios
SELECT relname as table , heap_blks_read as heap_read, heap_blks_hit as heap_hit, to_char( ( heap_blks_hit::decimal / ( heap_blks_hit::decimal + heap_blks_read::decimal ) ) * 100 , '99.99' ) FROM pg_statio_user_tables WHERE heap_blks_hit + heap_blks_read > 0 AND relid > 10000 ORDER BY relname;