title: Efficiency for many-to-one relationship
body: <p>Currently, we are building a commercial API as service.</p>
  
  <p>We have a following requirement.</p>
  
  <ol>
  <li>User will login via email</li>
  <li>Each user has a unique API key</li>
  <li>Every consumption of API, there will be a log for audit purpose.</li>
  </ol>
  
  <p>We plan to use the following custom user model.</p>
  
  <pre><code>class User(AbstractBaseUser):
      email = models.EmailField(
          verbose_name='email address',
          max_length=255,
          unique=True,
      )
      is_active = models.BooleanField(default=True)
      is_admin = models.BooleanField(default=False)
  
      objects = UserManager()
  
      USERNAME_FIELD = 'email'
  
      def __str__(self):
          return self.email
  
      def has_perm(self, perm, obj=None):
          "Does the user have a specific permission?"
          # Simplest possible answer: Yes, always
          return True
  
      def has_module_perms(self, app_label):
          "Does the user have permissions to view the app `app_label`?"
          # Simplest possible answer: Yes, always
          return True
  
      @property
      def is_staff(self):
          "Is the user a member of staff?"
          # Simplest possible answer: All admins are staff
          return self.is_admin
  
      def get_fields(self):
          return [(field.name, field.value_to_string(self)) for field in User._meta.fields]
  
  class Profile(models.Model):
      user = models.OneToOneField(User, on_delete=models.CASCADE)
      api_key = models.UUIDField(default=uuid.uuid4, editable=False, unique=True)
  
      def __str__(self):
          return str(self.api_key)
  
  class ApiLog(models.Model):
      api_consumed = models.TextField(blank=False, null=False)
      date_consumed = models.DateTimeField(auto_now=True)
      user = models.ForeignKey(User, on_delete=models.CASCADE)
  </code></pre>
  
  <p><strong>Is the above a good data models for Django?</strong></p>
  
  <p>Our worry is, a user will produce hundred thousand row of new <code>ApiLog</code> rows. We need not to access those data very frequent, unless when comes to audit period.</p>
  
  <p>However, we will construct existing <code>User</code> object very often. I was wondering, will a large number of row of <code>ApiLog</code> per <code>User</code>, will it slow down construction of existing. </p>
  
  <p>As, <code>User</code> object contains <code>user.apilog_set</code>, which may contains few hundred thousand line of rows.</p>