Grant access to partition in PostgreSQL - postgresql

I have a table that's scheduled for daily load. The table is partitioned based on each day i.e. the monthly table has 30 partition for month of Sep. I am granting select privileges' to couple of users. Do I also need to grant select access on the partition tables also to the end users. The data is in postgreSQL database.
Thanks

Related

Is there any way to delete or hide Automated Materialized Views (AutoMV) tables from redshift users

I copied the tables from 1 Redshift Database to another Redshift Database through amazon redshift snapshots.
After successfully copying the tables from 1 DB to another DB there are some auto generated redshift tables "pg_automv.*" created.
I tried drop table pg_automv.auto_mv_******** command but it shows Error running query: permission denied for schema pg_automv result
Is there any way to delete or hide these tables from a specific users

Dropping tables in a particular schema after X number of days from table creation date

I have a schema specific for temporary tables in redshift. Eventually, as creation of a lot of tables takes a lot of space, I would like to know the following:
Is there a way to automate deletion of tables in that schema after X days(lets say 30 days) after the table's creation date?
Any articles on the above question I can refer to?
Thanks.
You could start on Is there any way to find table creation date in redshift?
You can first collect the output to a temporary table and then run something that DROPs tables that have age over your threshold or you can do it in one step.

Minimum permission required to access Redshift External table

As per the AWS documentation,
To run a Redshift Spectrum query, you need the following permissions:
Usage permission on the schema
Permission to create temporary tables in the current database
I have an External database, schema and a table created in that schema.
I created a new Redshift user to which I granted 'usage' privileges on the external schema:
grant usage on external_schema to new_user;
But I did not provided 'temp' privileges on external_database to my new_user.
Also, there are no default privileges, as I checked PG_DEFAULT_ACL using master user and there are no rows in it.
Can someone let me know why I am able to query the external table?
In Amazon Redshift, Database and Schema are different concepts. User objects (Redshift and external) are created in Schema and TEMP objects are created in "temp" schemas and are available at database level.
In some cases, where join between Spectrum tables and Redshift tables is applied, Redshift needs to create temporary tables and that's why it is mentioned in documentation to avoid any failure/error for users.
Here is what documentation says:
Grants the privilege to create temporary tables in the specified database. To run Amazon Redshift Spectrum queries, the database user must have permission to create temporary tables in the database.
Note
By default, users are granted permission to create temporary tables by their automatic membership in the PUBLIC group. To remove the privilege for any users to create temporary tables, revoke the TEMP permission from the PUBLIC group. Then explicitly grant the permission to create temporary tables to specific users or groups of users.

how can i use table partition and row level secrity on tables together in postgresql?

I want to partition a table and then use row level security on those table to grant access to application users.Partition is based on organisation id and as such and is dynamic.

How to find "missing" rows in a Heroku Postgres database?

I keep getting emails that state the following:
"[Your database X] contains 16,919 rows, exceeding the plan limit of 10,000. INSERT privileges to the database will be automatically revoked in 7 days. This will cause service failures in most applications dependent on this database."
Even though I have limited the number of rows in my single table application to max 10 000, usually hovering at 9999.
I have checked the number of rows and the number of tables by psql and PGAdmin3.
Any idea how Heroku counts the number of rows in a database? Is this a platform bug or am I missing something?
Right now it makes estimated counts until you reach a certain threshold at which point it performs accurate counts (this mechanism subject to change). It will never revoke access or email a user without doing an accurate count first (SELECT count(*) FROM table1 + SELECT count(*) FROM table2 etc).
It does not count system tables; it considers all user level tables. Oftentimes people don't realize they have tables that are eating up rows, such as sessions, events or logs.