日日操夜夜添-日日操影院-日日草夜夜操-日日干干-精品一区二区三区波多野结衣-精品一区二区三区高清免费不卡

公告:魔扣目錄網(wǎng)為廣大站長(zhǎng)提供免費(fèi)收錄網(wǎng)站服務(wù),提交前請(qǐng)做好本站友鏈:【 網(wǎng)站目錄:http://www.ylptlb.cn 】, 免友鏈快審服務(wù)(50元/站),

點(diǎn)擊這里在線咨詢客服
新站提交
  • 網(wǎng)站:51998
  • 待審:31
  • 小程序:12
  • 文章:1030137
  • 會(huì)員:747

今天測(cè)試一下 1 億條數(shù)據(jù),MySQL 和 PostgreSQL 的性能表現(xiàn)。說明下,只是做一些基本的測(cè)試,并沒有用一些數(shù)據(jù)庫 Benchmark 工具進(jìn)行測(cè)試。

準(zhǔn)備

建表語句:

CREATE TABLE user_mysql / user_postgresql (
                                 id SERIAL PRIMARY KEY,
                                 username VARCHAR(50),
                                 emAIl VARCHAR(100),
                                 password VARCHAR(100),
                                 first_name VARCHAR(50),
                                 last_name VARCHAR(50),
                                 address VARCHAR(200),
                                 city VARCHAR(50),
                                 state VARCHAR(50),
                                 zip_code VARCHAR(10),
                                 country VARCHAR(50),
                                 phone_number VARCHAR(50),
                                 date_of_birth DATE,
                                 gender VARCHAR(10),
                                 occupation VARCHAR(100),
                                 education_level VARCHAR(50),
                                 registration_date TIMESTAMP,
                                 last_login TIMESTAMP,
                                 is_active BOOLEAN,
                                 is_admin BOOLEAN,
                                 additional_field1 VARCHAR(100),
                                 additional_field2 VARCHAR(100)
);

接下來記錄一下相關(guān)數(shù)據(jù)。

1.插入耗時(shí)

  • MySQL:≈ 67分鐘
  • PostgreSQL:≈ 55分鐘

2.count(*)耗時(shí)

MySQL:45 s 877 ms,明細(xì)如下:

mydatabase> select count(*) from user_mysql
[2023-09-26 22:22:24] 1 row retrieved starting from 1 in 45 s 877 ms (execution: 45 s 767 ms, fetching: 110 ms)

PostgreSQL:8 s 169 ms,明細(xì)如下:

postgres.public> select count(*) from user_postgresql
[2023-09-26 22:24:08] 1 row retrieved starting from 1 in 8 s 169 ms (execution: 8 s 133 ms, fetching: 36 ms)
今天測(cè)試一下 1 億條數(shù)據(jù),MySQL 和 PostgreSQL 的性能表現(xiàn)

1億數(shù)據(jù)量

3.根據(jù)主鍵查詢數(shù)據(jù)

MySQL:47 ms,明細(xì)如下:

mydatabase> select * from user_mysql where id = 19279833
[2023-09-26 22:28:10] 1 row retrieved starting from 1 in 47 ms (execution: 16 ms, fetching: 31 ms)

PostgreSQL:46 ms,明細(xì)如下:

postgres.public> select * from user_postgresql where id = 19279833
[2023-09-26 22:29:51] 1 row retrieved starting from 1 in 46 ms (execution: 15 ms, fetching: 31 ms)

4.根據(jù)username查詢(無索引)

MySQL:1 m 56 s 986 ms,明細(xì)如下:

// 查詢第99279833行數(shù)據(jù)
mydatabase> select * from user_mysql where username = '10190439674'
[2023-09-26 22:36:09] 1 row retrieved starting from 1 in 1 m 56 s 986 ms (execution: 1 m 56 s 939 ms, fetching: 47 ms)

PostgreSQL:38 s 73 ms,明細(xì)如下:

// 同樣查詢第99279833行數(shù)據(jù)
postgres.public> select * from user_postgresql where username = '14998727834'
[2023-09-26 22:38:25] 1 row retrieved starting from 1 in 38 s 73 ms (execution: 38 s 18 ms, fetching: 55 ms)

5.創(chuàng)建索引耗時(shí)

MySQL創(chuàng)建B+TREE索引:5 m 31 s 276 ms,明細(xì)如下:

mydatabase> ALTER TABLE user_mysql ADD INDEX idx_name (username)
[2023-09-26 22:47:37] completed in 5 m 31 s 276 ms

PostgreSQL創(chuàng)建B-TREE索引:9 m 20 s 847 ms,明細(xì)如下:

postgres.public> CREATE INDEX idx_name ON user_postgresql (username)
[2023-09-26 22:57:59] completed in 9 m 20 s 847 ms

6.根據(jù)username查詢(有索引)

MySQL:93 ms,明細(xì)如下:

// 查詢第99279833行數(shù)據(jù)
mydatabase> select * from user_mysql where username = '10190439674'
[2023-09-26 23:01:48] 1 row retrieved starting from 1 in 93 ms (execution: 0 ms, fetching: 93 ms)

PostgreSQL:63 ms,明細(xì)如下:

// 同樣查詢第99279833行數(shù)據(jù)
postgres.public> select * from user_postgresql where username = '14998727834'
[2023-09-26 23:00:07] 1 row retrieved starting from 1 in 63 ms (execution: 0 ms, fetching: 63 ms)

7.根據(jù)username修改(有索引)

MySQL:16 ms,明細(xì)如下:

mydatabase> update user_mysql set email='myemail' where username = '10190439674'
[2023-09-26 23:06:05] 1 row affected in 16 ms

PostgreSQL:15 ms,明細(xì)如下:

postgres.public> update user_postgresql set email='myemail' where username = '14998727834'
[2023-09-26 23:07:13] 1 row affected in 15 ms

8.分頁查詢(不加條件)

MySQL:1 m 40 s 265 ms,明細(xì)如下:

mydatabase> select * from user_mysql limit 89999980, 20
[2023-09-26 23:10:54] 20 rows retrieved starting from 1 in 1 m 40 s 265 ms (execution: 1 m 40 s 234 ms, fetching: 31 ms)

PostgreSQL:27 s 750 ms,明細(xì)如下:

postgres.public> select * from user_postgresql limit 20 offset 89999980
[2023-09-26 23:12:32] 20 rows retrieved starting from 1 in 27 s 750 ms (execution: 27 s 688 ms, fetching: 62 ms)

9.分頁查詢(加條件,條件為索引)

MySQL:94 ms,明細(xì)如下:

mydatabase> select * from user_mysql where id >= 89999980 limit 20
[2023-09-26 23:13:34] 20 rows retrieved starting from 1 in 94 ms (execution: 0 ms, fetching: 94 ms)

PostgreSQL:78 ms,明細(xì)如下:

postgres.public> select * from user_postgresql where id >= 89999980 limit 20
[2023-09-26 23:14:12] 20 rows retrieved starting from 1 in 78 ms (execution: 0 ms, fetching: 78 ms)

總結(jié)

在數(shù)據(jù)量達(dá)到1億時(shí),數(shù)據(jù)庫操作的開銷都會(huì)比較大,尤其是不走索引的操作和DDL操作等。因此在生產(chǎn)環(huán)境時(shí),不建議數(shù)據(jù)量太大,數(shù)據(jù)庫特別大的情況下,建議使用更強(qiáng)大的數(shù)據(jù)庫,不建議分表分庫。對(duì)大表進(jìn)行DDL操作時(shí)也需要謹(jǐn)慎操作。

聲明:這些數(shù)據(jù)均為本機(jī)測(cè)試,并未用專業(yè)測(cè)試軟件測(cè)試,僅供參考。

分享到:
標(biāo)簽:PostgreSQL
用戶無頭像

網(wǎng)友整理

注冊(cè)時(shí)間:

網(wǎng)站:5 個(gè)   小程序:0 個(gè)  文章:12 篇

  • 51998

    網(wǎng)站

  • 12

    小程序

  • 1030137

    文章

  • 747

    會(huì)員

趕快注冊(cè)賬號(hào),推廣您的網(wǎng)站吧!
最新入駐小程序

數(shù)獨(dú)大挑戰(zhàn)2018-06-03

數(shù)獨(dú)一種數(shù)學(xué)游戲,玩家需要根據(jù)9

答題星2018-06-03

您可以通過答題星輕松地創(chuàng)建試卷

全階人生考試2018-06-03

各種考試題,題庫,初中,高中,大學(xué)四六

運(yùn)動(dòng)步數(shù)有氧達(dá)人2018-06-03

記錄運(yùn)動(dòng)步數(shù),積累氧氣值。還可偷

每日養(yǎng)生app2018-06-03

每日養(yǎng)生,天天健康

體育訓(xùn)練成績(jī)?cè)u(píng)定2018-06-03

通用課目體育訓(xùn)練成績(jī)?cè)u(píng)定