It would be great if `optimize_on_insert` was smart enough to discard empty blocks
```
create table empty (num Int8) engine=Memory;
CREATE MATERIALIZED VIEW empty_mv
(
    `num` Int8
)
ENGINE = SummingMergeTree
ORDER BY tuple() AS
SELECT num
FROM empty;

-- First insert

set optimize_on_insert=1;
insert into empty values (0);

-- 20 minutes break

set optimize_on_insert=0;
insert into empty values (0);

-- Created parts

SELECT
    event_type,
    event_time,
    table,
    part_name,
    rows
FROM system.part_log
PREWHERE (event_date = today()) AND (table LIKE '%empty%')
ORDER BY event_time ASC
FORMAT PrettyCompactMonoBlock

┌─event_type─┬──────────event_time─┬─table───────────┬─part_name─┬─rows─┐
│ NewPart    │ 2021-02-10 21:27:40 │ .inner.empty_mv │ all_1_1_0 │    0 │
│ RemovePart │ 2021-02-10 21:27:42 │ .inner.empty_mv │ all_1_1_0 │    0 │
│ NewPart    │ 2021-02-10 21:46:42 │ .inner.empty_mv │ all_2_2_0 │    1 │
└────────────┴─────────────────────┴─────────────────┴───────────┴──────┘
```
sync_guard = disk->getDirectorySyncGuard(full_path);
    }
    if (metadata_snapshot->hasRowsTTL())
        updateTTL(metadata_snapshot->getRowsTTL(), new_data_part->ttl_infos, new_data_part->ttl_infos.table_ttl, block, true);
    for (const auto & ttl_entry : metadata_snapshot->getGroupByTTLs())
        updateTTL(ttl_entry, new_data_part->ttl_infos, new_data_part->ttl_infos.group_by_ttl[ttl_entry.result_column], block, true);
    for (const auto & ttl_entry : metadata_snapshot->getRowsWhereTTLs())
        updateTTL(ttl_entry, new_data_part->ttl_infos, new_data_part->ttl_infos.rows_where_ttl[ttl_entry.result_column], block, true);
    for (const auto & [name, ttl_entry] : metadata_snapshot->getColumnTTLs())
        updateTTL(ttl_entry, new_data_part->ttl_infos, new_data_part->ttl_infos.columns_ttl[name], block, true);
    const auto & recompression_ttl_entries = metadata_snapshot->getRecompressionTTLs();
    for (const auto & ttl_entry : recompression_ttl_entries)
        updateTTL(ttl_entry, new_data_part->ttl_infos, new_data_part->ttl_infos.recompression_ttl[ttl_entry.result_column], block, false);
    new_data_part->ttl_infos.update(move_ttl_infos);
    
    
    auto compression_codec = data.global_context.chooseCompressionCodec(0, 0);
    const auto & index_factory = MergeTreeIndexFactory::instance();
    MergedBlockOutputStream out(new_data_part, metadata_snapshot, columns, index_factory.getMany(metadata_snapshot->getSecondaryIndices()), compression_codec);
    bool sync_on_insert = data.getSettings()->fsync_after_insert;
    out.writePrefix();
    out.writeWithPermutation(block, perm_ptr);
    out.writeSuffixAndFinalizePart(new_data_part, sync_on_insert);
    ProfileEvents::increment(ProfileEvents::MergeTreeDataWriterRows, block.rows());
    ProfileEvents::increment(ProfileEvents::MergeTreeDataWriterUncompressedBytes, block.bytes());
    ProfileEvents::increment(ProfileEvents::MergeTreeDataWriterCompressedBytes, new_data_part->getBytesOnDisk());
    return new_data_part;
}
}