```
CREATE TABLE t (x UInt8, PROJECTION p (SELECT x GROUP BY x)) ENGINE = MergeTree ORDER BY ();
INSERT INTO t VALUES (0);

SET group_by_overflow_mode = 'any', max_rows_to_group_by = 1000, totals_mode = 'after_having_auto';
SELECT x FROM t GROUP BY x WITH TOTALS;
```
{
    if (getSettings()->in_memory_parts_enable_wal)
        return;
    auto metadata_snapshot = getInMemoryMetadataPtr();
    DataPartsVector parts = getDataPartsVectorForInternalUsage();
    for (const auto & part : parts)
    {
        if (auto part_in_memory = asInMemoryPart(part))
        {
            part_in_memory->flushToDisk(part_in_memory->getDataPartStorage().getPartDirectory(), metadata_snapshot);
        }
    }
}
size_t MergeTreeData::clearOldPartsFromFilesystem(bool force)
{
    DataPartsVector parts_to_remove = grabOldParts(force);
    clearPartsFromFilesystem(parts_to_remove);
    removePartsFinally(parts_to_remove);
    
    
    if (!parts_to_remove.empty())
        getContext()->dropMMappedFileCache();
    return parts_to_remove.size();
}
void MergeTreeData::clearPartsFromFilesystem(const DataPartsVector & parts, bool throw_on_error, NameSet * parts_failed_to_delete)