Skip to content

Specify Postgres schema #2633

Closed
Closed

Description

@rickb777

What do you want to change?

I am interested to use multiple schemas in Postgres. This can for example be used to handle multiple tenants in a single database. Although it's possible to share tables across tenants, it can be better to use more than one schema instead. This isolates each tenant's data from the others. It also reduces the performance costs of each tenant's db load from impacting other tenants because tables hold fewer lines.

Is there a way to use schemas via SQL statements in SQL?

Eg select * from tenant1.user,
where I can replace tenant1 accordingly?

What database engines need to be changed?

PostgreSQL

What programming language backends need to be changed?

Go

Activity

  1. added
    enhancementNew feature or request
    triageNew issues that hasn't been reviewed
    on Aug 18, 2023
  2. rickb777 commented on Aug 18, 2023

    @rickb777
    Author

    Additionally, switching schemas would be a useful feature for integration tests that need to be isolated from each other. Creating temporary schemas, using them during a test run, then tearing them down afterwards is a useful technique to allow partitioning such that different tests don't interfere with each other.

  3. rickb777 commented on Aug 18, 2023

    @rickb777
    Author

    BTW the current workaround is to set up each tenant to have its own default schema in Postgres (i.e. per user role), and then use a separate connection pool with the credentials for each tenant.

    This is clumsy and not ideal for the integration test use-casr.

  4. locked and limited conversation to collaborators on Aug 18, 2023
  5. converted this issue into a discussion #2635 on Aug 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesttriageNew issues that hasn't been reviewed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions