pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feed1-byte integers
2+ messages / 2 participants
[nested] [flat]
* 1-byte integers
@ 2004-09-17 21:40 stig erikson <stigerikson_nospam_@yahoo.se>
2004-09-18 15:39 ` Re: 1-byte integers Greg Stark <gsstark@mit.edu>
0 siblings, 1 reply; 2+ messages in thread
From: stig erikson @ 2004-09-17 21:40 UTC (permalink / raw)
To: pgsql-sql
how can i specify an integer to be one byte byte or even 4 bits long?
int1, int(1), tinyint are nowhere to be seen.
smallest i can find is smallint that is 2 bytes.
in a table i will have a few columns with values between 0 and 15, so
optimally i am looking for some kind of unsigned 4-bits, or (un)signed
integer (1-byte).
i can live with smallint for a while but estimate a few millions of rows
in the table to be a reality soon, in such cases every byte matters.
is there some
stig
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: 1-byte integers
2004-09-17 21:40 1-byte integers stig erikson <stigerikson_nospam_@yahoo.se>
@ 2004-09-18 15:39 ` Greg Stark <gsstark@mit.edu>
0 siblings, 0 replies; 2+ messages in thread
From: Greg Stark @ 2004-09-18 15:39 UTC (permalink / raw)
To: stig erikson <stigerikson_nospam_@yahoo.se>; +Cc: pgsql-sql
stig erikson <stigerikson_nospam_@yahoo.se> writes:
> how can i specify an integer to be one byte byte or even 4 bits long?
> int1, int(1), tinyint are nowhere to be seen.
> smallest i can find is smallint that is 2 bytes.
There's a type called "char" (the double quotes are needed). It's used by
postgres system catalogues but it's available for users too. It's a little
quirky since it has operators that treat it as a 1 byte text data type and
other operators that treat it as an integer data type. But that doesn't
normally lead to any problems, just strange symptoms when your code has a bug.
Other than that there are things like bit(4) which has a cast to and from
integer. But they won't save you any storage space. If you have multiple
columns like this and want to define a new type that aggregates them all for
storage but lets you access them individually that could be useful.
--
greg
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2004-09-18 15:39 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-09-17 21:40 1-byte integers stig erikson <stigerikson_nospam_@yahoo.se>
2004-09-18 15:39 ` Greg Stark <gsstark@mit.edu>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox