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 │
└────────────┴─────────────────────┴─────────────────┴───────────┴──────┘
```
using Data = HashMap<UInt128, size_t, UInt128TrivialHash>;
    Data partitions_map;
    size_t num_rows = columns[0]->size();
    size_t partitions_count = 0;
    for (size_t i = 0; i < num_rows; ++i)
    {
        Data::key_type key = hash128(i, columns.size(), columns);
        typename Data::LookupResult it;
        bool inserted;
        partitions_map.emplace(key, it, inserted);
        if (inserted)
        {
            if (max_parts && partitions_count >= max_parts)
                throw Exception("Too many partitions for single INSERT block (more than " + toString(max_parts) + "). The limit is controlled by 'max_partitions_per_insert_block' setting. Large number of partitions is a common misconception. It will lead to severe negative performance impact, including slow server startup, slow INSERT queries and slow SELECT queries. Recommended total number of partitions for a table is under 1000..10000. Please note, that partitioning is not intended to speed up SELECT queries (ORDER BY key is sufficient to make range queries fast). Partitions are intended for data manipulation (DROP PARTITION, etc).", ErrorCodes::TOO_MANY_PARTS);
            partition_num_to_first_row.push_back(i);
            it->getMapped() = partitions_count;
            ++partitions_count;
            
            if (partitions_count == 2)
            {
                selector = IColumn::Selector(num_rows);
                std::fill(selector.begin(), selector.begin() + i, 0);
            }
        }
        if (partitions_count > 1)
            selector[i] = it->getMapped();
    }
}
void updateTTL(