in core/lib/payload/copy.py [0:0]
def get_table_chunk_size(self):
"""
Calculate the number of rows for each table dump query table based on
average row length and the chunks size we've specified
"""
result = self.query(
sql.table_avg_row_len,
(
self._current_db,
self.table_name,
),
)
if result:
tbl_avg_length = result[0]["AVG_ROW_LENGTH"]
# avoid huge chunk row count
if tbl_avg_length < 20:
tbl_avg_length = 20
self.select_chunk_size = self.chunk_size // tbl_avg_length
# This means either the avg row size is huge, or user specified
# a tiny select_chunk_size on CLI. Let's make it one row per
# outfile to avoid zero division
if not self.select_chunk_size:
self.select_chunk_size = 1
log.info(
"TABLE contains {} rows, table_avg_row_len: {} bytes,"
"chunk_size: {} bytes, ".format(
result[0]["TABLE_ROWS"], tbl_avg_length, self.chunk_size
)
)
log.info("Outfile will contain {} rows each".format(self.select_chunk_size))
self.eta_chunks = max(
int(result[0]["TABLE_ROWS"] / self.select_chunk_size), 1
)
else:
raise OSCError("FAIL_TO_GUESS_CHUNK_SIZE")