楼主: 〇〇

postgresql 9.2的新功能测试

[复制链接]
论坛徽章:
407
紫蛋头
日期:2012-05-21 10:19:41迷宫蛋
日期:2012-06-06 16:02:49奥运会纪念徽章:足球
日期:2012-06-29 15:30:06奥运会纪念徽章:排球
日期:2012-07-10 21:24:24鲜花蛋
日期:2012-07-16 15:24:59奥运会纪念徽章:拳击
日期:2012-08-07 10:54:50奥运会纪念徽章:羽毛球
日期:2012-08-21 15:55:33奥运会纪念徽章:蹦床
日期:2012-08-21 21:09:51奥运会纪念徽章:篮球
日期:2012-08-24 10:29:11奥运会纪念徽章:体操
日期:2012-09-07 16:40:00
11#
 楼主| 发表于 2012-9-18 16:10 | 只看该作者
postgresql没有minus,但有except
test=# explain select max(a.info)from sli_test a where a.id in(select id from sli_test except select id from sli_test2 where id<5000);
                                                           QUERY PLAN
--------------------------------------------------------------------------------------------------------------------------------
Aggregate  (cost=220114.69..220114.70 rows=1 width=12)
   ->  Merge Semi Join  (cost=154083.92..218864.69 rows=500000 width=12)
         Merge Cond: (a.id = "ANY_subquery".id)
         ->  Index Scan using sli_test_pkey on sli_test a  (cost=0.00..32258.35 rows=1000000 width=16)
         ->  Materialize  (cost=154083.92..171606.34 rows=1000000 width=4)
               ->  Subquery Scan on "ANY_subquery"  (cost=154083.92..169106.34 rows=1000000 width=4)
                     ->  SetOp Except  (cost=154083.92..159106.34 rows=1000000 width=4)
                           ->  Sort  (cost=154083.92..156595.13 rows=1004485 width=4)
                                 Sort Key: "*SELECT* 1".id
                                 ->  Append  (cost=0.00..26478.69 rows=1004485 width=4)
                                       ->  Subquery Scan on "*SELECT* 1"  (cost=0.00..26274.00 rows=1000000 width=4)
                                             ->  Seq Scan on sli_test  (cost=0.00..16274.00 rows=1000000 width=4)
                                       ->  Subquery Scan on "*SELECT* 2"  (cost=0.00..204.69 rows=4485 width=4)
                                             ->  Index Only Scan using b_id on sli_test2  (cost=0.00..159.84 rows=4485 width=4)
                                                   Index Cond: (id < 5000)
(15 行记录)

使用道具 举报

回复
论坛徽章:
43
现任管理团队成员
日期:2011-05-07 01:45:08ITPUB元老
日期:2012-09-12 14:50:28版主5段
日期:2014-06-11 02:21:31阿斯顿马丁
日期:2013-11-19 10:38:16祖母绿
日期:2012-11-06 12:43:12路虎
日期:2013-11-20 11:37:53雪佛兰
日期:2013-09-05 13:28:25ITPUB9周年纪念徽章
日期:2010-10-08 09:28:512015中国数据库技术大会纪念徽章
日期:2015-04-24 16:04:24秀才
日期:2015-05-26 13:32:07
12#
发表于 2012-9-18 16:23 | 只看该作者
oo测测dm7,数据可以从postgre迁过去

使用道具 举报

回复
论坛徽章:
407
紫蛋头
日期:2012-05-21 10:19:41迷宫蛋
日期:2012-06-06 16:02:49奥运会纪念徽章:足球
日期:2012-06-29 15:30:06奥运会纪念徽章:排球
日期:2012-07-10 21:24:24鲜花蛋
日期:2012-07-16 15:24:59奥运会纪念徽章:拳击
日期:2012-08-07 10:54:50奥运会纪念徽章:羽毛球
日期:2012-08-21 15:55:33奥运会纪念徽章:蹦床
日期:2012-08-21 21:09:51奥运会纪念徽章:篮球
日期:2012-08-24 10:29:11奥运会纪念徽章:体操
日期:2012-09-07 16:40:00
13#
 楼主| 发表于 2012-9-18 16:32 | 只看该作者
myth8860 发表于 2012-9-18 16:23
oo测测dm7,数据可以从postgre迁过去

it01测了

使用道具 举报

回复
论坛徽章:
43
现任管理团队成员
日期:2011-05-07 01:45:08ITPUB元老
日期:2012-09-12 14:50:28版主5段
日期:2014-06-11 02:21:31阿斯顿马丁
日期:2013-11-19 10:38:16祖母绿
日期:2012-11-06 12:43:12路虎
日期:2013-11-20 11:37:53雪佛兰
日期:2013-09-05 13:28:25ITPUB9周年纪念徽章
日期:2010-10-08 09:28:512015中国数据库技术大会纪念徽章
日期:2015-04-24 16:04:24秀才
日期:2015-05-26 13:32:07
14#
发表于 2012-9-18 16:54 | 只看该作者
〇〇 发表于 2012-9-18 16:32
it01测了

嗯,01测的tpch,你这里测的是子查询吧?

使用道具 举报

回复
论坛徽章:
407
紫蛋头
日期:2012-05-21 10:19:41迷宫蛋
日期:2012-06-06 16:02:49奥运会纪念徽章:足球
日期:2012-06-29 15:30:06奥运会纪念徽章:排球
日期:2012-07-10 21:24:24鲜花蛋
日期:2012-07-16 15:24:59奥运会纪念徽章:拳击
日期:2012-08-07 10:54:50奥运会纪念徽章:羽毛球
日期:2012-08-21 15:55:33奥运会纪念徽章:蹦床
日期:2012-08-21 21:09:51奥运会纪念徽章:篮球
日期:2012-08-24 10:29:11奥运会纪念徽章:体操
日期:2012-09-07 16:40:00
15#
 楼主| 发表于 2012-9-19 09:28 | 只看该作者
myth8860 发表于 2012-9-18 16:54
嗯,01测的tpch,你这里测的是子查询吧?

你用我的例子贴出达梦的执行计划?

使用道具 举报

回复
论坛徽章:
43
现任管理团队成员
日期:2011-05-07 01:45:08ITPUB元老
日期:2012-09-12 14:50:28版主5段
日期:2014-06-11 02:21:31阿斯顿马丁
日期:2013-11-19 10:38:16祖母绿
日期:2012-11-06 12:43:12路虎
日期:2013-11-20 11:37:53雪佛兰
日期:2013-09-05 13:28:25ITPUB9周年纪念徽章
日期:2010-10-08 09:28:512015中国数据库技术大会纪念徽章
日期:2015-04-24 16:04:24秀才
日期:2015-05-26 13:32:07
16#
发表于 2012-9-19 10:26 | 只看该作者
〇〇 发表于 2012-9-19 09:28
你用我的例子贴出达梦的执行计划?

好的,我试试

使用道具 举报

回复
论坛徽章:
43
现任管理团队成员
日期:2011-05-07 01:45:08ITPUB元老
日期:2012-09-12 14:50:28版主5段
日期:2014-06-11 02:21:31阿斯顿马丁
日期:2013-11-19 10:38:16祖母绿
日期:2012-11-06 12:43:12路虎
日期:2013-11-20 11:37:53雪佛兰
日期:2013-09-05 13:28:25ITPUB9周年纪念徽章
日期:2010-10-08 09:28:512015中国数据库技术大会纪念徽章
日期:2015-04-24 16:04:24秀才
日期:2015-05-26 13:32:07
17#
发表于 2012-9-19 10:26 | 只看该作者
本帖最后由 myth8860 于 2012-9-19 10:41 编辑

create table sli_test (id int primary key,info varchar(20));

begin
for i in 1..1000000 loop
   insert into sli_test values(i,'digoal'||i);
   if mod(i,1000)=0 then
      commit;
   end if;
end loop;
end;
[执行语句1]:
begin
for i in 1..1000000 loop
   insert into sli_test values(i,'digoal'||i);
   if mod(i,1000)=0 then
      commit;
   end if;
end loop;
end;
执行成功, 耗时28秒532毫秒. 执行号:2,996,921


--这个没有postgre那种方式插入数据快

create table sli_test2 (id int not null,info varchar(20));

begin
for i in 1..1000000 loop
   insert into sli_test2 values(i,'digoal'||i);
   if mod(i,1000)=0 then
      commit;
   end if;
end loop;
end;

explain select max(b.info) from sli_test a,sli_test2 b where a.id=b.id;

#NSET2: [390, 1, 0]
  #PRJT2: [390, 1, 28]; exp_num(1), is_atom(FALSE)
    #AAGR2: [390, 1, 28]; grp_num(0), sfun_num(1)
      #HASH2 INNER JOIN: [390, 1000000, 28]; LKEY_UNIQUE KEY_NUM(1);
        #SSCN: [27, 1000000, 4]; INDEX33555470(sli_test)
        #CSCN2: [197, 1000000, 24]; INDEX33555471(sli_test2)


select max(b.info) from sli_test a,sli_test2 b where a.id=b.id;

[执行语句1]:
select max(b.info) from sli_test a,sli_test2 b where a.id=b.id;
执行成功, 耗时270毫秒. 执行号:2,996,933


explain select max(b.info) from sli_test a,sli_test2 b where a.id=b.id and a.id>500000;
#NSET2: [276, 1, 0]
  #PRJT2: [276, 1, 28]; exp_num(1), is_atom(FALSE)
    #AAGR2: [276, 1, 28]; grp_num(0), sfun_num(1)
      #HASH2 INNER JOIN: [276, 49500, 28]; LKEY_UNIQUE KEY_NUM(1);
        #SSEK2: [7, 50000, 4]; scan_type(ASC), INDEX33555470(sli_test), scan_range(,]
        #CSCN2: [197, 1000000, 24]; INDEX33555471(sli_test2)



select max(b.info) from sli_test a,sli_test2 b where a.id=b.id and a.id>500000;


[执行语句1]:
select max(b.info) from sli_test a,sli_test2 b where a.id=b.id and a.id>500000;
执行成功, 耗时234毫秒. 执行号:2,996,935

create index b_id on sli_test2(id);
[执行语句1]:
create index b_id on sli_test2(id);
执行成功, 耗时781毫秒. 执行号:2,996,996


explain select max(b.info) from sli_test a,sli_test2 b where a.id=b.id;
#NSET2: [390, 1, 0]
  #PRJT2: [390, 1, 28]; exp_num(1), is_atom(FALSE)
    #AAGR2: [390, 1, 28]; grp_num(0), sfun_num(1)
      #HASH2 INNER JOIN: [390, 1000000, 28]; LKEY_UNIQUE KEY_NUM(1);
        #SSCN: [27, 1000000, 4]; INDEX33555470(sli_test)
        #CSCN2: [197, 1000000, 24]; INDEX33555471(sli_test2)


explain select max(b.info) from sli_test a,sli_test2 b where a.id=b.id and a.id>500000;
#NSET2: [276, 1, 0]
  #PRJT2: [276, 1, 28]; exp_num(1), is_atom(FALSE)
    #AAGR2: [276, 1, 28]; grp_num(0), sfun_num(1)
      #HASH2 INNER JOIN: [276, 49500, 28]; LKEY_UNIQUE KEY_NUM(1);
        #SSEK2: [7, 50000, 4]; scan_type(ASC), INDEX33555470(sli_test), scan_range(,]
        #CSCN2: [197, 1000000, 24]; INDEX33555471(sli_test2)



SQL>select max(b.info) from sli_test a,sli_test2 b where a.id=b.id;

行号       MAX(b.info)
---------- ------------
1          digoal999999

已用时间: 288.128(ms) clock tick:106405104. Execute id is 2997001.


SQL>select max(b.info) from sli_test a,sli_test2 b where a.id=b.id and a.id>500000;

行号       MAX(b.info)
---------- ------------
1          digoal999999

已用时间: 297.448(ms) clock tick:150122588. Execute id is 2997000.


这几个查询的时间比postgre 似乎快一点,不过机器不一样,不具有可比性







使用道具 举报

回复
论坛徽章:
43
现任管理团队成员
日期:2011-05-07 01:45:08ITPUB元老
日期:2012-09-12 14:50:28版主5段
日期:2014-06-11 02:21:31阿斯顿马丁
日期:2013-11-19 10:38:16祖母绿
日期:2012-11-06 12:43:12路虎
日期:2013-11-20 11:37:53雪佛兰
日期:2013-09-05 13:28:25ITPUB9周年纪念徽章
日期:2010-10-08 09:28:512015中国数据库技术大会纪念徽章
日期:2015-04-24 16:04:24秀才
日期:2015-05-26 13:32:07
18#
发表于 2012-9-19 10:41 | 只看该作者
本帖最后由 myth8860 于 2012-9-19 10:50 编辑

--DM7对子查询做了深度的优化,计划是“平面”的
SQL>explain select max(a.info)from sli_test a where a.id not in(select b.id from sli_test2 b where b.id<50000);

#NSET2: [307, 1, 0]
  #PRJT2: [307, 1, 0]; exp_num(1), is_atom(FALSE)
    #AAGR2: [307, 1, 0]; grp_num(0), sfun_num(1)
      #HASH RIGHT SEMI JOIN2: [307, 50000, 0];  (ANTI),
        #PRJT2: [7, 50000, 4]; exp_num(1), is_atom(FALSE)
          #SSEK2: [7, 50000, 4]; scan_type(ASC), b_id(sli_test2), scan_range(,)
        #CSCN2: [197, 1000000, 24]; INDEX33555469(sli_test)

已用时间: 2.071(ms) clock tick:2010168. Execute id is 0.
SQL>select max(a.info)from sli_test a where a.id not in(select b.id from sli_test2 b where b.id<50000);

行号       MAX(a.info)
---------- ------------
1          digoal999999

已用时间: 156.033(ms) clock tick:136683312. Execute id is 2997002.


SQL>explain select max(a.info)from sli_test a where a.id in(select b.id from sli_test2 b  where b.id>=50000);

#NSET2: [307, 1, 0]
  #PRJT2: [307, 1, 0]; exp_num(1), is_atom(FALSE)
    #AAGR2: [307, 1, 0]; grp_num(0), sfun_num(1)
      #HASH RIGHT SEMI JOIN2: [307, 49500, 0];
        #SSEK2: [7, 50000, 4]; scan_type(ASC), b_id(sli_test2), scan_range[,]
        #CSCN2: [197, 1000000, 24]; INDEX33555469(sli_test)

已用时间: 1.966(ms) clock tick:1813680. Execute id is 0.


SQL>select max(a.info)from sli_test a where a.id in(select b.id from sli_test2 b where b.id>=50000);

行号       MAX(a.info)
---------- ------------
1          digoal999999

已用时间: 439.264(ms) clock tick:186240404. Execute id is 2997006.

使用道具 举报

回复
论坛徽章:
43
现任管理团队成员
日期:2011-05-07 01:45:08ITPUB元老
日期:2012-09-12 14:50:28版主5段
日期:2014-06-11 02:21:31阿斯顿马丁
日期:2013-11-19 10:38:16祖母绿
日期:2012-11-06 12:43:12路虎
日期:2013-11-20 11:37:53雪佛兰
日期:2013-09-05 13:28:25ITPUB9周年纪念徽章
日期:2010-10-08 09:28:512015中国数据库技术大会纪念徽章
日期:2015-04-24 16:04:24秀才
日期:2015-05-26 13:32:07
19#
发表于 2012-9-19 10:51 | 只看该作者
本帖最后由 myth8860 于 2012-9-19 10:52 编辑

--not exists
SQL>explain select max(a.info)from sli_test a where not exists(select 1 from sli_test2 b where b.id<50000 and a.id=b.id);

#NSET2: [307, 1, 0]
  #PRJT2: [307, 1, 0]; exp_num(1), is_atom(FALSE)
    #AAGR2: [307, 1, 0]; grp_num(0), sfun_num(1)
      #HASH RIGHT SEMI JOIN2: [307, 49500, 0];  (ANTI),
        #SSEK2: [7, 50000, 4]; scan_type(ASC), b_id(sli_test2), scan_range(,)
        #CSCN2: [197, 1000000, 32]; INDEX33555469(sli_test)

已用时间: 1.894(ms) clock tick:1405244. Execute id is 0.


使用道具 举报

回复
论坛徽章:
407
紫蛋头
日期:2012-05-21 10:19:41迷宫蛋
日期:2012-06-06 16:02:49奥运会纪念徽章:足球
日期:2012-06-29 15:30:06奥运会纪念徽章:排球
日期:2012-07-10 21:24:24鲜花蛋
日期:2012-07-16 15:24:59奥运会纪念徽章:拳击
日期:2012-08-07 10:54:50奥运会纪念徽章:羽毛球
日期:2012-08-21 15:55:33奥运会纪念徽章:蹦床
日期:2012-08-21 21:09:51奥运会纪念徽章:篮球
日期:2012-08-24 10:29:11奥运会纪念徽章:体操
日期:2012-09-07 16:40:00
20#
 楼主| 发表于 2012-9-19 10:56 | 只看该作者
myth8860 发表于 2012-9-19 10:41
--DM7对子查询做了深度的优化,计划是“平面”的
SQL>explain select max(a.info)from sli_test a where a ...

不错。

使用道具 举报

回复

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

TOP技术积分榜 社区积分榜 徽章 团队 统计 知识索引树 积分竞拍 文本模式 帮助
  ITPUB首页 | ITPUB论坛 | 数据库技术 | 企业信息化 | 开发技术 | 微软技术 | 软件工程与项目管理 | IBM技术园地 | 行业纵向讨论 | IT招聘 | IT文档
  ChinaUnix | ChinaUnix博客 | ChinaUnix论坛
CopyRight 1999-2011 itpub.net All Right Reserved. 北京盛拓优讯信息技术有限公司版权所有 联系我们 未成年人举报专区 
京ICP备16024965号-8  北京市公安局海淀分局网监中心备案编号:11010802021510 广播电视节目制作经营许可证:编号(京)字第1149号
  
快速回复 返回顶部 返回列表