我也跟风问个关于SQL的问题,请高人赐教。


我常常要query几个billion条记录的datasets,每次都至少要45分钟以上得到结果(remote) 。我昨天晚上用VPN联上database,噩梦,用了差不多2个小时。我在想,可不可以优化一下我的code让速度提高一点。比如说,

Proc sql;
Create table A as
Select ….
From DB1 inner join DB2 on a.keyword=b.keyword
Where controls;
Quit;

改成

Proc sql;
Create table A as
Select ……
From DB1 where controls and keyword in ( select keyword from B );
Quit;

这样会不会快一点?各位高大还有没有什么优化的高招?在些多谢啦。

我用SAS/SQL,我想基本原理跟SQL是一样的吧?

所有跟帖: 

如果TABLE DB1(a)比DB2(b)小很多,把=号的CONTROLS对调一下 -烟仔哥- 给 烟仔哥 发送悄悄话 烟仔哥 的博客首页 (30 bytes) () 11/10/2009 postreply 09:54:12

谢谢,好主意。 -veggiedoggie- 给 veggiedoggie 发送悄悄话 veggiedoggie 的博客首页 (297 bytes) () 11/10/2009 postreply 10:00:08

数据处理应该是在SERVER上的而不是客户端,只要有INDEX -烟仔哥- 给 烟仔哥 发送悄悄话 烟仔哥 的博客首页 (65 bytes) () 11/10/2009 postreply 10:26:19

你说得对,我查点资料看看,我记得好象advanced里有,考完就忘了。 -veggiedoggie- 给 veggiedoggie 发送悄悄话 veggiedoggie 的博客首页 (0 bytes) () 11/10/2009 postreply 10:39:18

妹妹你要加 index, create index .... -我边走边问- 给 我边走边问 发送悄悄话 我边走边问 的博客首页 (0 bytes) () 11/10/2009 postreply 09:55:58

呵呵,边边姐最近在猛K SAS呐?谢谢你,good idea. -veggiedoggie- 给 veggiedoggie 发送悄悄话 veggiedoggie 的博客首页 (0 bytes) () 11/10/2009 postreply 10:08:31

哎,副教主,这两天教猪那儿去了?俺想拍MP都找不到人了。 -烟仔哥- 给 烟仔哥 发送悄悄话 烟仔哥 的博客首页 (0 bytes) () 11/10/2009 postreply 10:32:19

啊,哈哈,你是:-}--~ -veggiedoggie- 给 veggiedoggie 发送悄悄话 veggiedoggie 的博客首页 (0 bytes) () 11/10/2009 postreply 10:38:10

不对,你是:-}---~,你抽的是大烟,烟杆特长。 -veggiedoggie- 给 veggiedoggie 发送悄悄话 veggiedoggie 的博客首页 (0 bytes) () 11/10/2009 postreply 10:44:01

yes -烟仔哥- 给 烟仔哥 发送悄悄话 烟仔哥 的博客首页 (0 bytes) () 11/10/2009 postreply 10:45:49

my suggestion... -HappyNow?!- 给 HappyNow?! 发送悄悄话 HappyNow?! 的博客首页 (449 bytes) () 11/10/2009 postreply 09:58:01

谢谢您 -veggiedoggie- 给 veggiedoggie 发送悄悄话 veggiedoggie 的博客首页 (286 bytes) () 11/10/2009 postreply 10:07:46

回复:谢谢您 -HappyNow?!- 给 HappyNow?! 发送悄悄话 HappyNow?! 的博客首页 (38 bytes) () 11/10/2009 postreply 10:12:38

good post, every DA should read this case -HappyNow?!- 给 HappyNow?! 发送悄悄话 HappyNow?! 的博客首页 (0 bytes) () 11/10/2009 postreply 10:31:57

谢谢您啦,老大,从您的贴子里受益很多。 -veggiedoggie- 给 veggiedoggie 发送悄悄话 veggiedoggie 的博客首页 (0 bytes) () 11/10/2009 postreply 10:40:19

回复:我也跟风问个关于SQL的问题,请高人赐教。 -nice2u- 给 nice2u 发送悄悄话 (449 bytes) () 11/10/2009 postreply 10:55:54

回复:回复:我也跟风问个关于SQL的问题,请高人赐教。 -veggiedoggie- 给 veggiedoggie 发送悄悄话 veggiedoggie 的博客首页 (246 bytes) () 11/10/2009 postreply 11:14:50

回复:回复:回复:我也跟风问个关于SQL的问题,请高人赐教。 -nice2u- 给 nice2u 发送悄悄话 (278 bytes) () 11/10/2009 postreply 11:26:14

having done some reading.... -撅着挺好- 给 撅着挺好 发送悄悄话 (899 bytes) () 11/10/2009 postreply 14:47:05

"IS NOT NULL" vs "IS NULL" -- -:))) -HappyNow?!- 给 HappyNow?! 发送悄悄话 HappyNow?! 的博客首页 (45 bytes) () 11/10/2009 postreply 15:20:46

good counterpart~~ -撅着挺好- 给 撅着挺好 发送悄悄话 (0 bytes) () 11/10/2009 postreply 16:21:17

Actually, join is much faster than embeded query (the 2nd one) -世界无童话- 给 世界无童话 发送悄悄话 世界无童话 的博客首页 (27 bytes) () 11/10/2009 postreply 17:42:44

请您先登陆,再发跟帖!