Bug #748 support for variable length ints
Submitted: 28 Jun 2003 13:04 Modified: 23 Jul 2003 13:50
Reporter: Daniel Penning Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S4 (Feature request)
Version: OS:
Assigned to: Peter Gulutzan CPU Architecture:Any

[28 Jun 2003 13:04] Daniel Penning
Description:
MySQL should support a type to store variable length numbers.
A good description how this could be achieved can be found under
http://jakarta.apache.org/lucene/docs/fileformats.html (Primitve Types - VInt)

quote:
A variable-length format for positive integers is defined where the high-order bit of each byte indicates whether more bytes remain to be read. The low-order seven bits are appended as increasingly more significant bits in the resulting integer value. Thus values from zero to 127 may be stored in a single byte, values from 128 to 16,383 may be stored in two bytes, and so on. 

How to repeat:
-
[28 Jun 2003 13:11] Daniel Penning
This might also be an efficient way to store short varchar strings.
[23 Jul 2003 13:50] Peter Gulutzan
Users do have a bit of control over integers of variable size: TINYINT takes one byte, 
SMALLINT takes two bytes, INT takes four bytes, and so on. But for short items, there is an 
advantage in fixed-size integers, because an UPDATE of the value won't cause a size 
change (size changes are relatively expensive actions). On the other hand, if one doesn't 
intend to update, then consideration of "packed" tables is in order -- see the MySQL 
Reference Manual's description of myisampack for this. As for character strings, we 
currently have variable-length storage (with VARCHAR). So  for the moment we'll consider 
this particular feature request "low priority" but we are going to work on various ideas for 
data compression, in future versions.