title: Firebase: Data Structure
body: <p><strong>When does the number of members within this node begin to affect performance ?</strong></p>
  
  <p>Example Node</p>
  
  <pre><code>Groups
      id_0
        groupName: Bills Cooking
        members
          uid_0: true
          uid_1: true
          uid_2: true
  </code></pre>
  
  <p>I am wondering when the number of keys within the <strong>members</strong> group becomes too many, and begins affect performance. </p>
  
  <p>Each group contains a reference id to all the members associated with it, there may be 0 or they could be 1000 or more. </p>
  
  <p>The members node (not show) would have their own reference indicating what groups they belong to. From my understanding this is a good way to structure your data in Firebase, having reference keys in both areas.</p>
  
  <p>If want to list all the group names in a tableview, I’d fetch all the group nodes to get their names. The problem is doing so I’m fetching all the members keys at the same time - I’m sure its fine for 10 or so I just wonder whats the point where you say - time to refactor. If there are 100 groups and 1000 users in each group - you are fetching a lot of extra data.</p>
  
  <p>I understand I could create another node and avoid this problem, but this is how Firebase recommends we structure the data. As detailed <a href="https://firebase.google.com/docs/database/ios/structure-data#fanout" rel="nofollow">here</a> </p>
  
  <p>Thanks</p>