Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Performance 64位服务器上PostgreSQL中int4和int8的性能差异_Performance_Postgresql_Integer - Fatal编程技术网

Performance 64位服务器上PostgreSQL中int4和int8的性能差异

Performance 64位服务器上PostgreSQL中int4和int8的性能差异,performance,postgresql,integer,Performance,Postgresql,Integer,假设PostgreSQL在64位服务器上运行,那么int4(32位)和int8(64位)列之间的性能差异是什么?该手册指出,int4比int8更高效,但如果底层服务器是64位的,是否存在实际性能差异(在(1)cpu、(2)内存和(3)存储方面)?在存储和内存方面,答案很明显:int8是int4的两倍大,因此,它使用了两倍的存储空间和两倍的内存 在计算(CPU)性能方面,我怀疑它在64位机器上没有任何区别,在某些情况下,INT4在32位机器上可能更有效。尽管除非你在这些整数上做复杂的数学运算(而不

假设PostgreSQL在64位服务器上运行,那么int4(32位)和int8(64位)列之间的性能差异是什么?该手册指出,int4比int8更高效,但如果底层服务器是64位的,是否存在实际性能差异(在(1)cpu、(2)内存和(3)存储方面)?

在存储和内存方面,答案很明显:int8是int4的两倍大,因此,它使用了两倍的存储空间和两倍的内存

在计算(CPU)性能方面,我怀疑它在64位机器上没有任何区别,在某些情况下,INT4在32位机器上可能更有效。尽管除非你在这些整数上做复杂的数学运算(而不仅仅是把它们当作一个序列,等等),计算的差异可能是零,或者非常接近零

而且,一旦您开始使用Int执行复杂的操作,实际上就不再是数据库性能问题了

在(1)cpu,(2)内存和(3)存储方面

直截了当地说:

  • 64位是32位的两倍大

  • 64位是32位的两倍大

  • 64位是32位的两倍大

  • 我记得wp黑客中的一个线程做了一些基准测试。创建一个表格,填写一百万行。然后查找、添加、分组、加入等等。我不记得具体细节,但使用int8确实比使用int4慢



    这是在什么机器上进行的?64位机器还是32位机器?
    test=# create table int4_test (id int primary key);
    CREATE TABLE
    test=# create table int8_test (id bigint primary key);
    CREATE TABLE
    test=# insert into int4_test select i from generate_series(1,1000000) i;
    INSERT 0 1000000
    test=# insert into int8_test select i from generate_series(1,1000000) i;
    INSERT 0 1000000
    test=# vacuum analyze;
    VACUUM
    test=# \timing on
    Timing is on.
    test=# select sum(i.id) from int4_test i natural join int4_test j where i.id % 19 = 0;
         sum     
    -------------
     26315710524
    (1 row)
    
    Time: 1364.925 ms
    test=# select sum(i.id) from int4_test i natural join int4_test j where i.id % 19 = 0;
         sum     
    -------------
     26315710524
    (1 row)
    
    Time: 1286.810 ms
    test=# select sum(i.id) from int8_test i natural join int8_test j where i.id % 19 = 0;
         sum     
    -------------
     26315710524
    (1 row)
    
    Time: 1610.638 ms
    test=# select sum(i.id) from int8_test i natural join int8_test j where i.id % 19 = 0;
         sum     
    -------------
     26315710524
    (1 row)
    
    Time: 1554.066 ms
    
    test=# select count(*) from int4_test i natural join int4_test j where i.id % 19 = 0;
     count 
    -------
     52631
    (1 row)
    
    Time: 1244.654 ms
    test=# select count(*) from int4_test i natural join int4_test j where i.id % 19 = 0;
     count 
    -------
     52631
    (1 row)
    
    Time: 1247.114 ms
    test=# select count(*) from int8_test i natural join int8_test j where i.id % 19 = 0;
     count 
    -------
     52631
    (1 row)
    
    Time: 1541.751 ms
    test=# select count(*) from int8_test i natural join int8_test j where i.id % 19 = 0;
     count 
    -------
     52631
    (1 row)
    
    Time: 1519.986 ms