Обсуждение: Fixed-point scalars?
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, PG 8.1.5 The closed-source RDBMS that we are hoping to archive on PostgreSQL 8.1.5 has fixed-point scalars, where the data is *stored* as a plain old scalar, but is run-time *interpreted* as having a decimal point. For example: SMALLINT(2) INTEGER(2) BIGINT(2) We use INTEGER(2) *extensively* for monetary values that won't exceed $21,474,836.47, and BIGINT(2) for those times where it might. This is very useful since integer arithmetic is so fast, and you know the field will always be 4 bytes. Are these data-types not in PG, or am I missing something? Also, how do you calculate the size of a NUMERIC? Lastly, I know they are the same, but which is the "preferred/standard" type: NUMERIC or DECIMAL? Thanks - -- Ron Johnson, Jr. Jefferson LA USA Is "common sense" really valid? For example, it is "common sense" to white-power racists that whites are superior to blacks, and that those with brown skins are mud people. However, that "common sense" is obviously wrong. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (GNU/Linux) iD8DBQFFNXl0S9HxQb37XmcRAsoiAJ0f8UGrYRm8eE3eX6EJYDJn6riV1wCfScHC J7l8E1S7WS++1wDxW/9k6b0= =zhgS -----END PGP SIGNATURE-----
On Oct 18, 2006, at 9:46 AM, Ron Johnson wrote: > SMALLINT(2) > INTEGER(2) > BIGINT(2) > Are these data-types not in PG, or am I missing something? http://www.postgresql.org/docs/current/interactive/ datatype.html#DATATYPE-NUMERIC The docs list 2 byte, 4 byte, and 8 byte integer types. > Also, how do you calculate the size of a NUMERIC? > > Lastly, I know they are the same, but which is the > "preferred/standard" type: NUMERIC or DECIMAL? Later on, same page: http://www.postgresql.org/docs/current/interactive/ datatype.html#DATATYPE-NUMERIC-DECIMAL > The actual storage requirement is two bytes for each group of four > decimal digits, plus eight bytes overhead. <snip /> > The types decimal and numeric are equivalent. Both types are part > of the SQL standard. The PostgreSQL are quite extensive and helpful. Michael Glaesemann grzm seespotcode net
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 10/17/06 22:14, Michael Glaesemann wrote: > > On Oct 18, 2006, at 9:46 AM, Ron Johnson wrote: > >> SMALLINT(2) >> INTEGER(2) >> BIGINT(2) > >> Are these data-types not in PG, or am I missing something? > > > http://www.postgresql.org/docs/current/interactive/datatype.html#DATATYPE-NUMERIC > > > The docs list 2 byte, 4 byte, and 8 byte integer types. Yes, I saw that, but did not know if other references were tucked away on a different page. >> Also, how do you calculate the size of a NUMERIC? >> >> Lastly, I know they are the same, but which is the >> "preferred/standard" type: NUMERIC or DECIMAL? > > Later on, same page: > > http://www.postgresql.org/docs/current/interactive/datatype.html#DATATYPE-NUMERIC-DECIMAL > > >> The actual storage requirement is two bytes for each group of four >> decimal digits, plus eight bytes overhead. Oh, now I see it. My eyes must have glazed over that paragraph. Eight bytes overhead? *Wow*. Combined with the lack of TINYINT, jumping from 4 bytes (which is what the current RDBMS uses) to 8+2 or 8+4 for money values is really going to increase record sizes. > <snip /> > >> The types decimal and numeric are equivalent. Knew that. > Both types are part of >> the SQL standard. Didn't know if one was out of fashion or not. > The PostgreSQL are quite extensive and helpful. - -- Ron Johnson, Jr. Jefferson LA USA Is "common sense" really valid? For example, it is "common sense" to white-power racists that whites are superior to blacks, and that those with brown skins are mud people. However, that "common sense" is obviously wrong. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (GNU/Linux) iD8DBQFFNgANS9HxQb37XmcRAkzEAJ9o/Hnv2u2Cu1G9Dny19T1V9hdwogCgjy4O zwALgdVyKqUohLKbLiuvHww= =UYQc -----END PGP SIGNATURE-----