0
votes

Below is a portion of statistics of one of my tables. I'm not sure how to understand width column. Are those values in bytes? If so, I know fname and lname have higher ascii char counts than 5 and 6 and there are some 1 char long values in mname.

Update 1. Below is the output of select * from statistics. I'm only showing first 5 columns of the ouput.

+--------+---------+------------------------+---------+-------+
| schema | table   | column                 | type    | width |
+========+=========+========================+=========+=======+
| abc    | targets | fname                  | varchar |     5 |
| abc    | targets | mname                  | varchar |     0 |
| abc    | targets | lname                  | varchar |     6 |
1
Where did you get these statics from?Hannes Mühleisen
@HannesMühleisen I updated the question, thanks.marcin_koss

1 Answers

0
votes

The column width shows the "byte-width of the atom array" (defined in gdk.h). This is however not the entire story in the case of string columns, because here the atom array only stores offsets into a string heap.

MonetDB uses variable-width columns, because if there are few distinct string values, 64-bit offsets would be a waste of memory. So in your case, the fname column needs string offsets with 5 bytes, or 40 bits, and lname needs 6 bytes (48 bits). This could change if new values are inserted.

The zero value for mname is interesting, because the width is initialised to 1 for new columns. Which version are you using?