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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:07:47+00:00 2026-06-15T20:07:47+00:00

I have a general database structure question. In my scenario I happen to be

  • 0

I have a general database structure question. In my scenario I happen to be using mongodb.

I’m creating an application where a user can upload a list of songs (title, artist, etc.) but am not sure if I should have one songList collection for all users or a separate songList.user# collection for each individual user. The users can only ever query songs associated to them so user A will NEVER know about user B’s songs.

Code Examples:

Multiple collections per user

db.songList.userA.find()
{"title": "Some song of user A", "artist": "Some artist of user A"}

db.songList.userB.find()
{"title": "Some song of user B", "artist": "Some artist of user B"}
  • Pros
    • Smaller collection size to query
  • Cons
    • Maintainability
      • 1,000 users means 1,000 collections

vs single collection with an owning ‘user’ field

db.songList.find({"user":"A"})
{"title": "Some song of user A", "artist": "Some artist of user A", "user": "A"}
  • Pros
    • Flexibility to query across users if need ever arised
  • Cons
    • Performance

I’m trying to build a pro/con list but still on the fence. Given that each user’s songs are going to be isolated from each other which approach is better? My main concern is maintenance and query performance.

Thanks in advance.

  • 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-15T20:07:48+00:00Added an answer on June 15, 2026 at 8:07 pm

    I would recommend NOT to make separate collection per user.

    Read the documentation

    By default MongoDB has a limit of approximately 24,000 namespaces per
    database. Each namespace is 628 bytes, the .ns file is 16MB by
    default.

    Each collection counts as a namespace, as does each index. Thus if
    every collection had one index, we can create up to 12,000
    collections. The –nssize parameter allows you to increase this limit
    (see below).

    Be aware that there is a certain minimum overhead per collection — a
    few KB. Further, any index will require at least 8KB of data space as
    the b-tree page size is 8KB. Certain operations can get slow if there
    are a lot of collections and the meta data gets paged out.

    So you won’t be able to gracefully handle it if your users exceed the namespace limit. Also it won’t be high on performance with the growth of your userbase.

    UPDATE

    As @Henry Liu mentioned in the comments. For Mongodb 3.0 or above using WiredTiger storage engine, it will no longer be the limit.

    docs.mongodb.org/manual/reference/limits/#namespaces

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

Sidebar

Related Questions

i have a general question : i'd like to develop a facebook application using
I have a general question about the way that database indexing works, particularly in
I have a general question that is rather open-ended (i.e. depends on platform, application
I just have a general database theory question. I have a need to make
I have a general question on the class definition and its use..THe below code
I have a general question about interpreters of functional languages: Are there actually any
I have a general question about the new Django 1.3 static file framework. I
I have a general OOP question. If I have the following classes in C#
I have a general question for the group. I am about to start a
Although this question fancies PostgreSQL, it is still a general DB question. I have

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.