def execute_sql(self, result_type=MULTI):
        # Modify query to fetch pks only and then execute the query
        # to get all pks.
        pk_field = self.query.model._meta.pk
        self.query.add_immediate_loading([pk_field.name])
        pks = [row for row in self.results_iter()]
        self.update_entities(pks, pk_field)
        return len(pks)