在我公司的虚拟机上测试PG性能

文章目录

  • 在我公司的虚拟机上测试PG性能
  • 是全部执行完再出来结果吗!

在我公司的虚拟机上测试PG性能

create database temp;
\c temp
create table TEST_A(id1 int ,id2 int ,id3 int ,id4 int);
insert into TEST_A select generate_series(1,10000),floor(random()*100),
floor(random()*100),floor(random()*100);
create table TEST_B(id1 int ,id2 int ,id3 int ,id4 int);
insert into TEST_B select generate_series(1,10000),floor(random()*100),
floor(random()*100),floor(random()*100);
select * from TEST_A,TEST_B where TEST_A.id2=TEST_B.id2;

\c postgres
drop database temp;

  • 1万行的时候
  • 可能叁万航就被killed掉了!
  • 哎!
temp=# explain analyze select * from TEST_A,TEST_B where TEST_A.id2=TEST_B.id2;QUERY PLAN                                                       
-----------------------------------------------------------------------------------------------------------------------Hash Join  (cost=280.00..11972.90 rows=998790 width=32) (actual time=3.217..281.075 rows=998790 loops=1)Hash Cond: (test_b.id2 = test_a.id2)->  Seq Scan on test_b  (cost=0.00..155.00 rows=10000 width=16) (actual time=0.030..2.017 rows=10000 loops=1)->  Hash  (cost=155.00..155.00 rows=10000 width=16) (actual time=3.172..3.173 rows=10000 loops=1)Buckets: 16384  Batches: 1  Memory Usage: 597kB->  Seq Scan on test_a  (cost=0.00..155.00 rows=10000 width=16) (actual time=0.007..1.172 rows=10000 loops=1)Planning Time: 0.139 msExecution Time: 321.802 ms
(8 rows)

如果是非等值连接,一万行就killed了!

  • 我用-c 20参数发现内存逐渐被耗尽

free -h -c 20

  • 而如果是=的话

是全部执行完再出来结果吗!

  • 没错!是的!
  • 是全部执行完才打印结果的!

  • 因为我调试过得
  • 直到ExecutePlan结束后
  • 命令行才出来结果的!


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部