Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the total size of a table in kdb+?

Tags:

kdb

I'm trying to find the memory usage of an in-memory table in q. How can I display this?

It is receiving live updates and I would like to keep track of the total used memory of such a table.

I can't seem to find any relevant functions/commands for this. I need something like hcount for file locations, but an in-memory version.

like image 907
Jean-Paul Avatar asked Dec 15 '22 16:12

Jean-Paul


1 Answers

-22! returns the size in bytes of in-memory objects. e.g.

  q)t:([] a:til 1000)
  q)-22!t
8031
  q)/ 1000 longs = 1000*8 bytes + a small header
  q)t:([] a:til 2000)
  q)-22!t
16031

If you are interested in how memory management in kdb works I recommend this tutorial: http://www.timestored.com/kdb-guides/memory-management (Disclaimer: I wrote it.)

like image 165
Ryan Hamilton Avatar answered Dec 24 '22 11:12

Ryan Hamilton