# The KDB + memory mechanism is what?

**URL:** <https://forum.kx.com/t/the-kdb-memory-mechanism-is-what/8579>\
**Category:** Community Support\
**Tags:** kdb-and-q\
**Created:** [January 12, 2014, 12:22pm UTC](https://forum.kx.com/t/the-kdb-memory-mechanism-is-what/8579 "2014-01-12T12:22:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![huangyuanfei14](https://avatars.discourse-cdn.com/v4/letter/h/47e85d/32.png) [@huangyuanfei14](https://forum.kx.com/u/huangyuanfei14)\
**Post date:** [January 12, 2014, 12:22pm UTC](https://forum.kx.com/t/the-kdb-memory-mechanism-is-what/8579/1 "2014-01-12T12:22:00Z")

</div>

If I need 2 terabytes of data to calculate.But I only 100 Gb of memory, How to solve the problem of large data than the memory?The KDB + memory mechanism is what?

Thanks

---

<div class="post-metadata">

**Author:** ![wp1](https://avatars.discourse-cdn.com/v4/letter/w/db5fbb/32.png) [@wp1](https://forum.kx.com/u/wp1)\
**Post date:** [January 12, 2014, 12:30pm UTC](https://forum.kx.com/t/the-kdb-memory-mechanism-is-what/8579/2 "2014-01-12T12:30:00Z")

</div>

assuming you are dealing with timeseries data, you should partition your data by date/month/year.  
Have a look at kdb for mortals:?http://code.kx.com/wiki/JB:KdbplusForMortals/partitioned\_tables

It covers the basics databases on disk quite extensively.

---

<div class="post-metadata">

**Author:** ![AE1](https://avatars.discourse-cdn.com/v4/letter/a/97f17d/32.png) [@AE1](https://forum.kx.com/u/AE1)\
**Post date:** [January 15, 2014, 4:48pm UTC](https://forum.kx.com/t/the-kdb-memory-mechanism-is-what/8579/3 "2014-01-15T16:48:00Z")

</div>

Hello,

I have a question related to the main question.

For example, I have large amount of historical data, which does not fit in memory.

hst:([obj\_id:4020 4050 4050] change\_date:2012.09.13 2012.09.12 2012.09.20; change:(“10-\>20”; “22-\>33”; “33-\>55”)) / and more data

select count distinct obj\_id from hst

~10^7

count hst

~20^8

change\_date interval:5 years.

I need ability to retrive list of changes for every object fast. It is clear and we cannot split it by day or month, because we have to read all partitions in this case.

If we have it partitioned by object - there will be tons of small files of partitions - I am not sure if it is ok.

Are there any other solution except duplicate 2 databases if I need both abilities: to retrieve history for one object and retrieve history for the period?

Thank you,

? Alexander.

---

<div class="post-metadata">

**Author:** ![pressjonny0](https://avatars.discourse-cdn.com/v4/letter/p/ccd318/32.png) [@pressjonny0](https://forum.kx.com/u/pressjonny0)\
**Post date:** [January 20, 2014, 9:08am UTC](https://forum.kx.com/t/the-kdb-memory-mechanism-is-what/8579/4 "2014-01-20T09:08:00Z")

</div>

Hi

If you are working with 32bit kdb+, then it is going to be very difficult to stick inside the 4GB memory limit without introducing some form of partitioning. &nbsp;I wouldn’t think you could partition by object ID without exceeded file system limitations, but you could maybe partition by objectID group (e.g. objects 0 -\> 10k live in one partition, 10k -\> 20k live in another etc.). &nbsp;Assuming there are 26 bn records, 10m object IDs, that would give 2500 records per object (approx). &nbsp;There might be a balance you could find where you could work sensibly with the data, maybe objectID groups of 10k IDs, which would give 1000 partitions with 25m rows in each, and you might be able to work with that without hitting the 4GB memory limit too often (assuming you have the data with `p# on object ID and you use that as your first lookup field everytime).&nbsp;

If you have 64bit then you have lots more options. &nbsp;For example, you could save it as one large splayed table with a `p# on obj\_id, but that might be difficult to manage in itself (hard to sort etc.).&nbsp;

Thanks&nbsp;

Jonny
