Re: [PERFORM] NUMERIC x VARCHAR
On Tue, 2004-08-10 at 23:42, Er Galvo Abbott wrote: Greetings. I have a question regarding performance of certain datatypes: I have a field where I will store my clients phone numbers. I know that this field will never exceed 15 characters, and I will store only numbers here (no dashes, dots, etc...), so I was wondering: Wich type is faster: NUMERIC(15,0) or VARCHAR(15)? Are there any storage differences between them? Since numerics are stored as text strings, the storage would be similar. Numerics, however, may be slower since they have more constraints built in. If you throw a check constraint on the varchar(15) then it will likely be about the same speed for updating. text type with a check contraint it what i'd use. That way if you want to change it at a later date you just drop and recreate your constraint. ---(end of broadcast)--- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faqs/FAQ.html
Re: [PERFORM] NUMERIC x VARCHAR
Numeric won't store that : (+33) 4 01 23 45 67 On Wed, 11 Aug 2004 02:42:33 -0300, Er Galvão Abbott [EMAIL PROTECTED] wrote: Greetings. I have a question regarding performance of certain datatypes: I have a field where I will store my clients phone numbers. I know that this field will never exceed 15 characters, and I will store only numbers here (no dashes, dots, etc...), so I was wondering: Wich type is faster: NUMERIC(15,0) or VARCHAR(15)? Are there any storage differences between them? TIA, ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://archives.postgresql.org
Re: [PERFORM] NUMERIC x VARCHAR
On Aug 11, 2004, at 4:27 PM, Er Galvão Abbott wrote: It will. As I've said I wont be storing any symbols. It won't store leading zeros, however. This may or may not be an issue for you. test=# create table tel (name_id integer not null, tel_numeric numeric(15) not null, tel_varchar varchar(15) not null); CREATE TABLE test=# insert into tel (name_id, tel_numeric, tel_varchar) values (1,012345678911234, '012345678911234'); INSERT 17153 1 test=# select * from tel; name_id | tel_numeric | tel_varchar -++- 1 | 12345678911234 | 012345678911234 (1 row) I would do as another poster suggested: create a telephone number domain as text with the check constraints you desire. Michael Glaesemann grzm myrealbox com ---(end of broadcast)--- TIP 7: don't forget to increase your free space map settings
Re: [PERFORM] NUMERIC x VARCHAR
Thanks, Michael. You and "Evil Azrael" (lol) got me. Never thought about leading zeros. Varchar it is! Thanks a lot, -- Er Galvo Abbott Desenvolvedor Web http://www.galvao.eti.br/ [EMAIL PROTECTED] Michael Glaesemann wrote: On Aug 11, 2004, at 4:27 PM, Er Galvo Abbott wrote: It will. As I've said I wont be storing any symbols. It won't store leading zeros, however. This may or may not be an issue for you. test=# create table tel (name_id integer not null, tel_numeric numeric(15) not null, tel_varchar varchar(15) not null); CREATE TABLE test=# insert into tel (name_id, tel_numeric, tel_varchar) values (1,012345678911234, '012345678911234'); INSERT 17153 1 test=# select * from tel; name_id | tel_numeric | tel_varchar -++- 1 | 12345678911234 | 012345678911234 (1 row) I would do as another poster suggested: create a telephone number domain as text with the check constraints you desire. Michael Glaesemann grzm myrealbox com
[PERFORM] NUMERIC x VARCHAR
Greetings. I have a question regarding performance of certain datatypes: I have a field where I will store my clients phone numbers. I know that this field will never exceed 15 characters, and I will store only numbers here (no dashes, dots, etc...), so I was wondering: Wich type is faster: NUMERIC(15,0) or VARCHAR(15)? Are there any storage differences between them? TIA, -- Er Galvo Abbott Desenvolvedor Web http://www.galvao.eti.br/ [EMAIL PROTECTED]