title: Reduce Django serialization time
body: <p>I am doing queries for roughly 100,000 rows with approximately 40 column each. The columns are of combination of float, integer, datetime, and char.</p>
  
  <p>The query time is about two seconds, and serialization is taking forty seconds or more, whereas response building is about two seconds too.</p>
  
  <p>I am wondering how can I reduce serialization time for Django models?</p>
  
  <p>Here is my model:</p>
  
  <pre><code>class TelematicsData(models.Model):
      id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
  
      device = models.ForeignKey(Device, on_delete=models.CASCADE, null=True)
  
      created_date = models.DateTimeField(auto_now=True)
  
      analog_input_01 = models.FloatField(null=True)
      analog_input_02 = models.FloatField(null=True)
      analog_input_03 = models.FloatField(null=True)
      analog_input_04 = models.FloatField(null=True)
      analog_input_05 = models.FloatField(null=True)
      analog_input_06 = models.FloatField(null=True)
  
      device_temperature = models.FloatField(null=True)
      device_voltage = models.FloatField(null=True)
      vehicle_voltage = models.FloatField(null=True)
  
      absolute_acceleration = models.FloatField(null=True)
      brake_acceleration = models.FloatField(null=True)
      bump_acceleration = models.FloatField(null=True)
      turn_acceleration = models.FloatField(null=True)
      x_acceleration = models.FloatField(null=True)
      y_acceleration = models.FloatField(null=True)
      z_acceleration = models.FloatField(null=True)
  
      cell_location_error_meters = models.FloatField(null=True)
      engine_ignition_status = models.NullBooleanField()
  
      gnss_antenna_status = models.NullBooleanField()
      gnss_type = models.CharField(max_length=20, default='NA')
      gsm_signal_level = models.FloatField(null=True)
      gsm_sim_status = models.NullBooleanField()
  
      imei = models.CharField(max_length=20, default='NA')
      movement_status = models.NullBooleanField()
      peer = models.CharField(max_length=20, default='NA')
  
      position_altitude = models.IntegerField(null=True)
      position_direction = models.FloatField(null=True)
      position_hdop = models.IntegerField(null=True)
      position_latitude = models.DecimalField(max_digits=9, decimal_places=6, null=True)
      position_longitude = models.DecimalField(max_digits=9, decimal_places=6, null=True)
      position_point = models.PointField(null=True)
      position_satellites = models.IntegerField(null=True)
      position_speed = models.FloatField(null=True)
      position_valid = models.NullBooleanField()
  
      shock_event = models.NullBooleanField()
      hardware_version = models.FloatField(null=True)
      software_version = models.FloatField(null=True)
  
      record_sequence_number = models.IntegerField(null=True)
      timestamp_server = models.IntegerField(null=True)
      timestamp_unix = models.IntegerField(null=True)
      timestamp = models.DateTimeField(null=True)
      vehicle_mileage = models.FloatField(null=True)
  
      user_data_value_01 = models.FloatField(null=True)
      user_data_value_02 = models.FloatField(null=True)
      user_data_value_03 = models.FloatField(null=True)
      user_data_value_04 = models.FloatField(null=True)
      user_data_value_05 = models.FloatField(null=True)
      user_data_value_06 = models.FloatField(null=True)  
      user_data_value_07 = models.FloatField(null=True)  
      user_data_value_08 = models.FloatField(null=True)
  </code></pre>
  
  <p>and this is the serializer:</p>
  
  <pre><code>class TelematicsDataSerializer(serializers.ModelSerializer):
  
      class Meta:
          model = TelematicsData
          geo_field = ('position_point')
          #fields = '__all__'
          exclude = ['id']
  </code></pre>