On Tue, May 28, 2013 at 10:15 AM, Wang, Gao <wan...@gmail.com> wrote:

> Dear all,
>
> I use sqlite to store, query and perform simple math operations on large
> datasets of small integers -- all values I have in the dataset are -1, 0, 1
> and 2. These integers are stored as INTEGER (4 byte). I desperately need a
> way to reduce the size of my database because I have dozens of databases
> like this with size ~100G which takes too much of my storage. I'd like some
> other integer type for {-1,0,1,2} such as "SMALLINT" (
> http://www.sqlite.org/datatype3.html). I understand sqlite data types are
> dynamic and it does not make a difference to create a field of type
> SMALLINT. I wonder if there are something I can do to fulfill my need.
> Anyway to hack into the sqlite.c codes?
>
>
SQLite does not allocate 4 bytes to every integer.  It uses a variable
number of bytes (between 1 and 9) depending on the magnitude of the
integer.  See http://www.sqlite.org/fileformat2.html#record_format for
additional information.  Values of 0 and 1 take 1 bytes.  Values of -1 and
2 take two bytes.

See also the sqlite3_analyzer.exe utility.  Running sqlite3_analyzer.exe on
one of your database files might give you a better idea of where space is
being used.

-- 
D. Richard Hipp
d...@sqlite.org
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to