3

How can I read the size of a table (in bytes) in Q?

I know that hcount returns the size of a file in bytes, but I can't find something similar for tables (or in general any object...)

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Chris Taylor
  • 46,912
  • 15
  • 110
  • 154

3 Answers3

2

−22!x is an optimised shortcut to count -8!x

q)(-22!trade)~count -8!trade
1b
q)\t:100 count -8!trade
3596
q)\t:100 -22!trade
839
Mark Kelly
  • 1,780
  • 7
  • 16
1

this is serialized (wire) object size
play around with \w this will give you object size in memory

q)a:til 10000
q)count -8!a
40014
q)\w
176464 67108864 67108864 0 0 2137387008j
q)b:til 10000
q)\w
242000 67108864 67108864 0 0 2137387008j
q)242000-176464
65536
q)\ts b,a
0 131200j
q)131248%2
65624f
q)
bua
  • 4,761
  • 1
  • 26
  • 32
0

After some searching, it appears that count -8!tablename does the trick.

Chris Taylor
  • 46,912
  • 15
  • 110
  • 154