# Collecting items from the Flow in chunks💦

DevFeed: [Collecting items from the Flow in chunks💦](<https://devfeed.tech/articles/collecting-items-from-the-flow-in-chunks-25706.md>)

Original publisher: [Read original article](<https://blog.shreyaspatil.dev/collecting-items-from-the-flow-in-chunks/>)

Author: Shreyas Patil

Published: 2023-10-23T04:46:23Z

Content type: tutorial

Language: en

Sources: [Shreyas Patil's Blog](<https://devfeed.tech/sources/shreyas-patil-s-blog.md>)

Topics: [coroutines-flow](<https://devfeed.tech/topics/coroutines-flow.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Streaming](<https://devfeed.tech/topics/streaming.md>), [batch insert](<https://devfeed.tech/topics/batch-insert.md>)

Tags: [analytics](<https://devfeed.tech/tags/analytics.md>), [coroutines](<https://devfeed.tech/tags/coroutines.md>), [database](<https://devfeed.tech/tags/database.md>), [flow](<https://devfeed.tech/tags/flow.md>), [implementation](<https://devfeed.tech/tags/implementation.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [kotlin-coroutines](<https://devfeed.tech/tags/kotlin-coroutines.md>), [multithreading](<https://devfeed.tech/tags/multithreading.md>), [network](<https://devfeed.tech/tags/network.md>), [persistence](<https://devfeed.tech/tags/persistence.md>), [processing](<https://devfeed.tech/tags/processing.md>), [reactive-programming](<https://devfeed.tech/tags/reactive-programming.md>), [streams](<https://devfeed.tech/tags/streams.md>)

## AI overview

For high-frequency Flow data such as analytics events, collecting items over time intervals can reduce the cost of repeated database or network operations and keep that work from competing as often with higher-priority app tasks. The excerpt contrasts this time-based batching need with collection chunking by item count and introduces a custom Flow operator intended to emit chunks at fixed intervals. It does not include the implementation or explain how the operator handles timing and data retention.

## Source excerpt

Learn how to collect Kotlin Flow items in chunks or intervals without losing data. A practical guide to handling high-frequency data streams efficiently.