Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7035665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:19:52+00:00 2026-05-28T01:19:52+00:00

in the database there are many identical schemas, cmp01 .. cmpa0 each schema has

  • 0

in the database there are many identical schemas, cmp01..cmpa0

each schema has a users table

each schema’s users table’s primary key has its own unique range

for example, in cmp01.users the usr_id is between 0x01000000 and 0x01ffffffff.

is there any way I could define a VIEW global.users that is a union of each of the cmp*.union tables in such a way that, if querying by usr_id, the optimizer would head for the correct schema?

was thinking something like:

create view global.users as
select * from cmp01.users where usr_id between 0x01000000 and 0x01ffffffff
union all
select * from cmp02.users where usr_id between 0x02000000 and 0x02ffffffff
....

would this work? NO. EXPLAIN ANALYZE shows all schema used.

Is there an approach that might give good hints to the optimizer?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T01:19:53+00:00Added an answer on May 28, 2026 at 1:19 am

    What about creating a partitioned table? The master table would be created as global.users and it would be partitioned by the schema name.

    That way you’d get the small user tables in each schema (including fast retrievals) provided you can create queries that PostgreSQL can optimize i.e. including the schema name in the where condition. You could also create a view in each schema that would hide the needed schema name to query the partitioned tables. I don’t think it would work by specifying only the user_id. I fear that PostgreSQL’s partitioning features are not smart enough for that.

    Or use just one single table, and create views in each schema with an instead of trigger and limiting the result to that schema’s users.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a legacy mysql database and there's this table which has a few
I know there are many database design tool, database modeling tool. Example, ER-win ,
I know that there are many Delphi database related questions available, but I'm considering
In a MySQL (5.1) database table there is data that represents: how long a
In my SQL database there're many fields like this: Field Type:Text Null:Yes Default:NULL My
I know Core Data is not a database and there are many differences. Is
How many database systems there are that use JSON for storage or transport? I
I have two MySQL databases with identical table structure, each populated with several thousand
I'm building a MySQL database of vehicles. There are many different possible vehicle attributes
There is a html table which data are from a MySql database , got

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.