Skip to main content

Posts

Showing posts from 2019

View Partitioning Child table settings - Postgres

I have been an agent of change in my pod and the staff I have been waving is postgres :). We have been working out a new project and the OLTP data store is postgres. Out of the many things I encountered this week two things really topped the list.  Most OLTP workload are random IO. Postgres heep vs cluster key that sorts data  Declarative partitioning is the way forward to keeping data sets manageble and assists with maintenance tasks. The code snippet for bellow provides details of the partition child table properties.    SELECT    nmsp_parent.nspname AS parent_schema,    parent.relname      AS parent,    nmsp_child.nspname  AS child_schema,    child.relname       AS child ,    pg_get_expr(child.relpartbound, child.oid, true) as child_expression,    child.reloptions   FROM pg_inher...

Default privileges Don't work when owner changes

One of the first things you learn in  postgres  is the importance of getting the default privileges configured. Coming from the  SQLserver  background, I found having to assign default privileges a little precarious but once I got over that hump it has become more obvious for its place in PG.  The other day I discovered that default privileges don't get inherited of the new owner when the ownership changes of an object. 1.) login as  postgres   create table tab(id int)  2.) login as d_owner  create table  taba (id int) 3.) Grant permission for  readonly  role access data from the public schema owned by d_owner grant select on all tables in schema public to  readrole ; alter default privileges for user  d_owner   in schema public grant select on tables to feedsapi_readonly_role 4.) Change the owner of  tab  from  postgres  to d_owner     ...