postgresql-int,bigint,numeric效率測試
阿新 • • 發佈:2019-01-03
在postgresql9.5的時候做過一個測試就是sum()的效率最終的測試結果是sum(int)>sum(numeric)>sum(bigint)當時比較詫異為啥sum(bigint)效率比sum(numeric)還低。sum(numeric)的效率比sum(bigint)快了10%。
在pg10版本的時候對sum()的效能做了優化,pg10.4
最終的測試結果為pg10的效率大幅提升,sum(int)>sum(bigint)>sum(numeric),當一個表中有bigint,int時,誰放在第一列效率要高點。但是差別不是很大,效率都比numeric高。
bigint for smallint or int arguments, numeric for bigint arguments, otherwise the same as the argument data type
這次主要做abase5.0測試,以及pg11 jit測試。
插入1kw資料測試。
這裡只是輸出型別的轉換,並不會太影響效率。 numeric的算術運算比整數型別要慢很多。 通過求助,最終了解到可能和pg的元組變形(tuple deform)有關, 這次建立三張表分別對應三種資料型別。 create table t_int(n_int int); create table t_bigint(n_bigint bigint); create table t_numeric(n_numeric numeric); insert into t_int select generate_series(1,10000000); insert into t_bigint select generate_series(1,10000000); insert into t_numeric select generate_series(1,10000000);