code: def insert_select_max(self):
          
          if self._insert_select_max is None:
              if hasattr(self.record_class, 'application_name'):
                  # Todo: Maybe make it support application_name without pipeline_id?
                  assert hasattr(self.record_class, 'pipeline_id'), self.record_class
                  tmpl = self._insert_select_max_tmpl + self._where_application_name_tmpl
              else:
                  tmpl = self._insert_select_max_tmpl
              self._insert_select_max = self._prepare_insert(
                  tmpl=tmpl,
                  record_class=self.record_class,
                  field_names=list(self.field_names),
              )
          return self._insert_select_max
docs: SQL statement that inserts records with contiguous IDs,
          by selecting max ID from indexed table records.