# Columnar Table is consuming Memory

**URL:** <https://www.singlestore.com/forum/t/columnar-table-is-consuming-memory/3619>\
**Category:** Workload Profiling\
**Created:** [December 13, 2021, 11:40am UTC](https://www.singlestore.com/forum/t/columnar-table-is-consuming-memory/3619 "2021-12-13T11:40:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![moralez.rodrigo](https://www.singlestore.com/forum/letter_avatar_proxy/v4/letter/m/f19dbf/32.png) [@moralez.rodrigo](https://www.singlestore.com/forum/u/moralez.rodrigo)\
**Post date:** [December 13, 2021, 11:40am UTC](https://www.singlestore.com/forum/t/columnar-table-is-consuming-memory/3619/1 "2021-12-13T11:40:40Z")

</div>

I’m seeing that most of the columnar tables are consuming memory, causing oom issues. Do you what could be causing this?

TABLE INFO  
Memory Usage  
1.5 GB  
Disk Usage  
1.5 GB  
Row Count  
5.72M rows  
Table Type  
Columnstore table  
Table Compression  
82.37%

**CREATE**  **TABLE** `table_columnstore` (

`raw_json` JSON **COLLATE** utf8\_bin,

`name` **as** raw\_json::$name PERSISTED **varchar** (35) **CHARACTER**  **SET** utf8 **COLLATE** utf8\_general\_ci,

`platform` **as** raw\_json::$platform PERSISTED **varchar** (10) **CHARACTER**  **SET** utf8 **COLLATE** utf8\_general\_ci,

`env` **as** raw\_json::$env PERSISTED **varchar** (15) **CHARACTER**  **SET** utf8 **COLLATE** utf8\_general\_ci,

`user` **as** raw\_json::$player\_id PERSISTED **varchar** (38) **CHARACTER**  **SET** utf8 **COLLATE** utf8\_general\_ci,

`date` **as**  **date** ( **FROM\_UNIXTIME** (raw\_json::%unixts)) PERSISTED **date** ,

`timestamp_utc` **as**  **FROM\_UNIXTIME** (raw\_json::%unixts) PERSISTED **datetime** ,

`inserted_at` **timestamp**  **NOT**  **NULL**  **DEFAULT**  **CURRENT\_TIMESTAMP** ,

`game_ver` **as** raw\_json::$game\_ver PERSISTED **varchar** (25) **CHARACTER**  **SET** utf8 **COLLATE** utf8\_general\_ci,

**KEY** `events` (`date_utc`,`environment`,`player_id`,`timestamp_utc`) **USING** CLUSTERED COLUMNSTORE,

SHARD **KEY** `key` (`date`,`env`,`user`)

) AUTOSTATS\_CARDINALITY\_MODE=INCREMENTAL AUTOSTATS\_HISTOGRAM\_MODE= **CREATE** AUTOSTATS\_SAMPLING= **ON** SQL\_MODE=‘STRICT\_ALL\_TABLES’

---

<div class="post-metadata">

**Author:** ![hanson](https://www.singlestore.com/forum/user_avatar/www.singlestore.com/hanson/32/196_2.png) [@hanson](https://www.singlestore.com/forum/u/hanson)\
**Post date:** [December 23, 2021, 3:19pm UTC](https://www.singlestore.com/forum/t/columnar-table-is-consuming-memory/3619/2 "2021-12-23T15:19:42Z")

</div>

SingleStore columnstore tables contain an in-memory rowstore segment for recently-inserted or updated rows. It’s normal for some memory to be used by a columnstore. In a large columnstore, the in-memory rowstore segment will contain only a fraction of the total data. The rest will be in disk-based columnstore format. Some of that will be cached in memory in the file system buffer cache.

If you do OPTIMIZE TABLE FLUSH, it will write the in-memory data to disk. If you do that and restart your system, then check memory usage by the columnstore, you might see that it is less. But really, this is just a curiosity – it is not necessary to do this in normal operation because the system automatically flushes data in the background.

---

<div class="post-metadata">

**Author:** ![moralez.rodrigo](https://www.singlestore.com/forum/letter_avatar_proxy/v4/letter/m/f19dbf/32.png) [@moralez.rodrigo](https://www.singlestore.com/forum/u/moralez.rodrigo)\
**Post date:** [December 27, 2021, 11:10am UTC](https://www.singlestore.com/forum/t/columnar-table-is-consuming-memory/3619/3 "2021-12-27T11:10:13Z")

</div>

Thank you @hanson that command reduced from 1.3GB of memory to 250M, Do you know why this isn’t being cleaned automatically?

The table is being loaded from a pipeline with batches every 60000 milis.

---

<div class="post-metadata">

**Author:** ![moralez.rodrigo](https://www.singlestore.com/forum/letter_avatar_proxy/v4/letter/m/f19dbf/32.png) [@moralez.rodrigo](https://www.singlestore.com/forum/u/moralez.rodrigo)\
**Post date:** [December 27, 2021, 11:46am UTC](https://www.singlestore.com/forum/t/columnar-table-is-consuming-memory/3619/4 "2021-12-27T11:46:03Z")

</div>

well… now it’s back to 1.3GB of memory again… seems that the buffer is too high
