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 8658057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:40:26+00:00 2026-06-12T15:40:26+00:00

I am not facing this issue , but always comes to my mind ..

  • 0

I am not facing this issue , but always comes to my mind .. Of course this is only after replicating data , using memcached and partitioning …

If I have photo_tbl and structure is like below

user_id
group_id
date_added
.... and many more 

on user profile we show user photo by running below query

SELECT ...... FROM photo_tbl WHERE user_id=? order by date_added desc 

on groups page we show groups photos by running below query

SELECT ...... FROM photo_tbl WHERE group_id=? order by date_added desc 

In this case if the rows are billions and if requires sharding on what key do you use without impacting performance for the above two queries ..?

If my sharded key is user_id , for groups I have to go multiple databases to get the desired results ( by changing application logic) .. if it is on group_id for users profile , I have to go to multiple databases to get the desired results.

  • 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-06-12T15:40:27+00:00Added an answer on June 12, 2026 at 3:40 pm

    You basically have two “shard trees”. You need to shard by user and by group. If you attempt this in a single table then one way will always require a query across all shards, which isn’t so bad if you have an efficient way of doing this. For instance, with dbShards you can run efficient queries in parallel across shards (we call these “Go Fish” queries).

    There are two other options to consider:

    1. Duplicate the table and have one sharded by user and one sharded by group. All reads will be against a single shard but you have to write twice.

    2. Use three tables. Photo table sharded by photo id. user_photos (user_id, photo_id, and other fields) sharded by user. group_photos (group_id, photo_id, and other fields) sharded by group.

    We see these scenarios a lot and these are the usual approaches our customers take.

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

Sidebar

Related Questions

I am facing a strange issue.It is working well with outlook 2K3 but not
I am facing this issue on IE7 only, when I am scrolling the page:
This if for an internal CMS, so it's not public facing. I have my
Not being used to php, I'm facing an issue with accessing arrays and its
I am facing a dilemma related to another question but not exactly the same.
I am facing one issue and I am not sure if what i would
Facing a problem, it seems my data stored in SQL Server does not stored
I am facing an issue with SecureRandom in java. This was the code that
I'm facing a weird actions by codeiginter especially when it comes to using different
I am facing an issue in basic authentication ,for which I am not able

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.