Search Postgresql Archives

Performance difference between char and int2 columns

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



hi everybody.
 
i have two table as :
 
CREATE TABLE "public"."tb_section_phones" (
  "section_id" INTEGER NOT NULL,
  "ptype_id" INTEGER NOT NULL,
  "country_code" SMALLINT DEFAULT 90,
  "domain_code" SMALLINT,
  "number" CHAR(7) NOT NULL,
  "extension" VARCHAR(6),
  CONSTRAINT "tb_section_phones_fk" FOREIGN KEY ("section_id")
    REFERENCES "public"."tb_sections"("sect_id")
    ON DELETE CASCADE
    ON UPDATE CASCADE
    NOT DEFERRABLE,
  CONSTRAINT "tb_section_phones_fk1" FOREIGN KEY ("ptype_id")
    REFERENCES "public"."tb_phone_types"("ptype_id")
    ON DELETE CASCADE
    ON UPDATE CASCADE
    NOT DEFERRABLE
) WITHOUT OIDS;
 
 
CREATE TABLE "public"."tb_section_phones_temp" (
  "sect_id" INTEGER NOT NULL,
  "ptype_id" INTEGER NOT NULL,
  "country_code" CHAR(2) DEFAULT 90,
  "domain_code" CHAR(3),
  "number" CHAR(7) NOT NULL,
  "extension" VARCHAR(6),
  CONSTRAINT "tb_section_phones_fk" FOREIGN KEY ("sect_id")
    REFERENCES "public"."tb_sections"("sect_id")
    ON DELETE CASCADE
    ON UPDATE CASCADE
    NOT DEFERRABLE,
  CONSTRAINT "tb_section_phones_fk2" FOREIGN KEY ("ptype_id")
    REFERENCES "public"."tb_phone_types"("ptype_id")
    ON DELETE CASCADE
    ON UPDATE CASCADE
    NOT DEFERRABLE
) WITHOUT OIDS;
 
the differences between two table are :
in the first table country_code type is smallint, in the second table char(2)
in the first table domain_code type is smallint, in the second table char(3)
.
 
The problem is that:
my both table has 10 records.
when i run this query on first table :
   select * from tb_section_phones;
   it lasts 0.02 sec.
when i run this query on second table :
   select * from tb_section_phones_temp;
   it lasts 0.13 sec.
 
6.5 times slower.
why so performance difference?
should i prefer int as column type?
 
thanks in advance.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux