avatar
P*e
1
嗯嗯,这里的MM心灵手巧~发这里问问~
最近去逛Sears,那个Clearance区买了十来条牛仔裤,本来是要穿S或Petite系列的,
但是有些确实太实惠了,又好看大小也合适,自己一贪心下定决心就抱回来了,就是裤
脚太长。
姐妹们帮帮忙啊,自己怎么收牛仔裤的裤脚?有没有贤淑达人能提供个步骤一类的>.<
多谢!!!
avatar
B*g
2
请看附件。谢谢
TAB_A 8M records
TAB_B 0.2M records
subquery TAB_B will return 1-5 rows for most of records in TAB_B(except
around 20).
现在我要用 IN,即使sub里面只有一个return,至少10分钟还没有结束。要是用 =,
只要几秒钟。试过各种hint,都没能成功。暂时我把SQL改成了PL/SQL(loop
subquery 里面),想知道只用SQL砸搞。
Note: 由于公司政策,table/column名字不能公开。
avatar
h*a
3
代码如下
public class StringRead{
public static void main(String[] args){
String s = args[0];
String s0 = "ab";
if (s == s0) System.out.println("s == s0");
String s1 = "ab";
String s2 = "ab";
if (s1 == s2) System.out.println("s1 == s2");
}
}
编译成功后运行 java StringRead ab (读入"ab"赋值给args)
打印结果是 s1 == s2
为什么 s == s0 return false 但是 s1 == s2 return true?
谢谢!
avatar
c*d
5
能用Join就不用subquery

【在 B*****g 的大作中提到】
: 请看附件。谢谢
: TAB_A 8M records
: TAB_B 0.2M records
: subquery TAB_B will return 1-5 rows for most of records in TAB_B(except
: around 20).
: 现在我要用 IN,即使sub里面只有一个return,至少10分钟还没有结束。要是用 =,
: 只要几秒钟。试过各种hint,都没能成功。暂时我把SQL改成了PL/SQL(loop
: subquery 里面),想知道只用SQL砸搞。
: Note: 由于公司政策,table/column名字不能公开。

avatar
g*g
6
It's because "ab"=="ab" but "ab" != new String("ab")

【在 h*******a 的大作中提到】
: 代码如下
: public class StringRead{
: public static void main(String[] args){
: String s = args[0];
: String s0 = "ab";
: if (s == s0) System.out.println("s == s0");
: String s1 = "ab";
: String s2 = "ab";
: if (s1 == s2) System.out.println("s1 == s2");
: }

avatar
P*e
7
多谢MM!!!!
对了,好期待MM的手工再在换版上造福大家~~~嘻嘻

【在 f******y 的大作中提到】
: mm,试试这个法子行不行http://sh.talk.iyaya.com/29/1-380483-0.html
: 我一般是用这个方法,虽然这个法子没那种剪掉的改来好看,不过可以防止剪错尺寸。

avatar
B*g
8
我试join不行, 给个提示吧。

【在 c*****d 的大作中提到】
: 能用Join就不用subquery
avatar
h*a
9
Got it! Thanks!

【在 g*****g 的大作中提到】
: It's because "ab"=="ab" but "ab" != new String("ab")
avatar
l*m
10
对付裤脚太长的问题,我一般用高跟鞋。。。
avatar
c*t
11
did you check the difference of execution plans?

【在 B*****g 的大作中提到】
: 请看附件。谢谢
: TAB_A 8M records
: TAB_B 0.2M records
: subquery TAB_B will return 1-5 rows for most of records in TAB_B(except
: around 20).
: 现在我要用 IN,即使sub里面只有一个return,至少10分钟还没有结束。要是用 =,
: 只要几秒钟。试过各种hint,都没能成功。暂时我把SQL改成了PL/SQL(loop
: subquery 里面),想知道只用SQL砸搞。
: Note: 由于公司政策,table/column名字不能公开。

avatar
d*g
12
这个也就是个偶然吧?不同编译器可能有不同结果的。不觉得specification会要求s1=
=s2

【在 h*******a 的大作中提到】
: Got it! Thanks!
avatar
P*e
13
汗,我个子不高,平常爱穿高跟的,不过都没有超过8厘米。太高又怕脚疼。
这次确实是太贪心了,好多裤子买回来其实是Miss的号我穿了高跟还长>.<
就打算按fishbaby MM说的那个方法试试了,只是从来针线活就很不会,顶多钮子掉了
能勉强缝上去。我慢慢缝缝试试看。

【在 l****m 的大作中提到】
: 对付裤脚太长的问题,我一般用高跟鞋。。。
avatar
g*g
15
In hotspot, all literal Strings point to the same instance directly or
indirectly. Not sure that's a spec requirement though.

s1=

【在 d****g 的大作中提到】
: 这个也就是个偶然吧?不同编译器可能有不同结果的。不觉得specification会要求s1=
: =s2

avatar
B*g
16
不明白

【在 c**t 的大作中提到】
: did you check the difference of execution plans?
avatar
d*g
17
It actually IS guranteed by spec... :( Weird
http://stackoverflow.com/questions/767372/java-string-equals-ve
also, "abc" == "ab" + "c" as well.

【在 g*****g 的大作中提到】
: In hotspot, all literal Strings point to the same instance directly or
: indirectly. Not sure that's a spec requirement though.
:
: s1=

avatar
s*s
19
为什么 "ab" != new String("ab") ?

【在 g*****g 的大作中提到】
: It's because "ab"=="ab" but "ab" != new String("ab")
avatar
c*t
20
check your execution plan, see why the IN operator is slow

【在 B*****g 的大作中提到】
: 不明白
avatar
F*n
21
Java String *大多数* 指向Constant pool
但由 new String(java.lang.String)生成的String指向新的object
这些是相等的
"aa"
new String({'a', 'a'})
(new StringBuilder("aa")).toString()
这个不等
new String("aa");

【在 s****s 的大作中提到】
: 为什么 "ab" != new String("ab") ?
avatar
S*t
22
the plan was attached.
Full index scan took a long time, that part needs to be tuned.

【在 c**t 的大作中提到】
: check your execution plan, see why the IN operator is slow
avatar
o*1
23
这叫 Flyweight pattern.
当你直接使用 "ab" 的时候,是建一次以后再使用"ab"都是share同一个 object
节省内存。
所以 "ab"=="ab"
但是 new String("ab") 就是新建一个 object 就不相等了。
符号 == 不是检查 value 是否相等,是检查是否指向同一个 object
建string 的时候都要用 "some string", 不要 new String("ddd")

【在 s****s 的大作中提到】
: 为什么 "ab" != new String("ab") ?
avatar
B*g
24
zan.
俺没搞出来, 水平的不行.

【在 S*********t 的大作中提到】
: the plan was attached.
: Full index scan took a long time, that part needs to be tuned.

avatar
s*s
25
你的意思
"aa" == new String({'a', 'a'})
"aa" == (new StringBuilder("aa")).toString()
这两个怎么解释?

【在 F****n 的大作中提到】
: Java String *大多数* 指向Constant pool
: 但由 new String(java.lang.String)生成的String指向新的object
: 这些是相等的
: "aa"
: new String({'a', 'a'})
: (new StringBuilder("aa")).toString()
: 这个不等
: new String("aa");

avatar
c*d
26
上午在telnet下面没注意到你贴了执行计划
用subquery应该可以提高效率,不过要在tab_b上创建函数索引
另外可以试试加一个使用tab_b作为驱动表的hint,这个应该更方便

【在 B*****g 的大作中提到】
: zan.
: 俺没搞出来, 水平的不行.

avatar
F*n
27
These two are not created by new String(java.lang.String),
so will point to the constant pool

【在 s****s 的大作中提到】
: 你的意思
: "aa" == new String({'a', 'a'})
: "aa" == (new StringBuilder("aa")).toString()
: 这两个怎么解释?

avatar
f*n
28
“现在我要用 IN,即使sub里面只有一个return,至少10分钟还没有结束。要是用 =,
只要几秒钟。试过各种hint,都没能成功。”
我以前做过优化,是Oracle 8,9,现在的产品都不是很清楚了,所以我的想法,楼主
仅当建议听听。“至少10分钟还没有结束”可能是执行了全表搜索之类的费时操作(
即使你是用PLSQL之类优化过了),一种方法是对关键字做索引,但这种方法对于很大
的table可能还是有问题,即使你看了执行计划里面,仍然会有这种情况。那么另一种
情况就是优化你的语句,我记得Oracle里面有个设置是可以设置每次系统一次可以读取
多少数据记录块,如果默认的数值相对太少了,也会导致检索的时候频繁读盘,最后是
系统强制全表搜索的情况,你可以设置这个参数。另外一个方案就是把大表拆散分散存
储,不过貌似你的情况还没有到这种地步。还有一种可能,是你的SQL语句书写的问题
,一般上从关系代数(不记得具体名字了)上检查一下优化一下,也是可能的,我就有
碰到过要查询1小时的SQL,优化过只要5分钟不到的情况。
祝你顺利。
avatar
t*i
29
try this one?
select a.a_col0 from tab_A a, (select to_char(B.B_col1) as col3 from tab_B B
where B.B_col2 in (to_number(:variable_0, '9999999'))) c
where a.a_col4=c.col3
and a.a_col1='P'
and a.col2 = 'U'
and a.col3 between to_date (....)
avatar
B*g
30
我现在就是在优化sql,搞不定

=,

【在 f********n 的大作中提到】
: “现在我要用 IN,即使sub里面只有一个return,至少10分钟还没有结束。要是用 =,
: 只要几秒钟。试过各种hint,都没能成功。”
: 我以前做过优化,是Oracle 8,9,现在的产品都不是很清楚了,所以我的想法,楼主
: 仅当建议听听。“至少10分钟还没有结束”可能是执行了全表搜索之类的费时操作(
: 即使你是用PLSQL之类优化过了),一种方法是对关键字做索引,但这种方法对于很大
: 的table可能还是有问题,即使你看了执行计划里面,仍然会有这种情况。那么另一种
: 情况就是优化你的语句,我记得Oracle里面有个设置是可以设置每次系统一次可以读取
: 多少数据记录块,如果默认的数值相对太少了,也会导致检索的时候频繁读盘,最后是
: 系统强制全表搜索的情况,你可以设置这个参数。另外一个方案就是把大表拆散分散存
: 储,不过貌似你的情况还没有到这种地步。还有一种可能,是你的SQL语句书写的问题

avatar
B*g
31
我连with都试过了,没用。

B

【在 t*********i 的大作中提到】
: try this one?
: select a.a_col0 from tab_A a, (select to_char(B.B_col1) as col3 from tab_B B
: where B.B_col2 in (to_number(:variable_0, '9999999'))) c
: where a.a_col4=c.col3
: and a.a_col1='P'
: and a.col2 = 'U'
: and a.col3 between to_date (....)

avatar
B*g
32
hint用tab_b驱动试过了,各种join也试过了。没有权限create index,有了也不行。
俺门公司只让用b-tree, 其它一概不许用.

【在 c*****d 的大作中提到】
: 上午在telnet下面没注意到你贴了执行计划
: 用subquery应该可以提高效率,不过要在tab_b上创建函数索引
: 另外可以试试加一个使用tab_b作为驱动表的hint,这个应该更方便

avatar
t*i
33
现在我要用 IN,即使sub里面只有一个return,至少10分钟还没有结束。要是用 =,
只要几秒钟。
****************************************************************************
which 'in' are you talking about?
1) where B.B_col2 in (to_number(:variable_0, '9999999'))?
2) and a.a_col4 in (select ...
avatar
B*g
34
please look the attached image.

**

【在 t*********i 的大作中提到】
: 现在我要用 IN,即使sub里面只有一个return,至少10分钟还没有结束。要是用 =,
: 只要几秒钟。
: ****************************************************************************
: which 'in' are you talking about?
: 1) where B.B_col2 in (to_number(:variable_0, '9999999'))?
: 2) and a.a_col4 in (select ...

avatar
c*d
35
不用create index
只是用tab_b做驱动表,能把执行计划贴一下吗?

【在 B*****g 的大作中提到】
: hint用tab_b驱动试过了,各种join也试过了。没有权限create index,有了也不行。
: 俺门公司只让用b-tree, 其它一概不许用.

avatar
c*d
36
又一个没看到附件的

=,

【在 f********n 的大作中提到】
: “现在我要用 IN,即使sub里面只有一个return,至少10分钟还没有结束。要是用 =,
: 只要几秒钟。试过各种hint,都没能成功。”
: 我以前做过优化,是Oracle 8,9,现在的产品都不是很清楚了,所以我的想法,楼主
: 仅当建议听听。“至少10分钟还没有结束”可能是执行了全表搜索之类的费时操作(
: 即使你是用PLSQL之类优化过了),一种方法是对关键字做索引,但这种方法对于很大
: 的table可能还是有问题,即使你看了执行计划里面,仍然会有这种情况。那么另一种
: 情况就是优化你的语句,我记得Oracle里面有个设置是可以设置每次系统一次可以读取
: 多少数据记录块,如果默认的数值相对太少了,也会导致检索的时候频繁读盘,最后是
: 系统强制全表搜索的情况,你可以设置这个参数。另外一个方案就是把大表拆散分散存
: 储,不过貌似你的情况还没有到这种地步。还有一种可能,是你的SQL语句书写的问题

avatar
B*g
37
*****本贴有附件*****
Hope I use hint correctly.
*****本贴有附件*****
我看谁还看不到附件,哈哈

【在 c*****d 的大作中提到】
: 不用create index
: 只是用tab_b做驱动表,能把执行计划贴一下吗?

avatar
c*d
38
试一下这个
select /*+ first_rows */ a.a_col0
...
或者这个
select /*+ use_nl(tab_b) */ a.a_col0

【在 B*****g 的大作中提到】
: *****本贴有附件*****
: Hope I use hint correctly.
: *****本贴有附件*****
: 我看谁还看不到附件,哈哈

avatar
B*g
39
use_nl(b), use_nl(b a) 都试过了,不灵。
just try first_rows,不灵。
结论:
1. sql不是万能的,必要时pl/sql更好。
2. table statistic 有问题
3. 用telnet的人很多。

【在 c*****d 的大作中提到】
: 试一下这个
: select /*+ first_rows */ a.a_col0
: ...
: 或者这个
: select /*+ use_nl(tab_b) */ a.a_col0

avatar
S*t
40
试过之后 plan 有变化吗?

【在 B*****g 的大作中提到】
: use_nl(b), use_nl(b a) 都试过了,不灵。
: just try first_rows,不灵。
: 结论:
: 1. sql不是万能的,必要时pl/sql更好。
: 2. table statistic 有问题
: 3. 用telnet的人很多。

avatar
c*d
41
嗯,这也是我想问的
能贴一下exec plan

【在 S*********t 的大作中提到】
: 试过之后 plan 有变化吗?
avatar
c*d
42
那连接方法呢?是用nestloop了还是hash

【在 B*****g 的大作中提到】
: use_nl(b), use_nl(b a) 都试过了,不灵。
: just try first_rows,不灵。
: 结论:
: 1. sql不是万能的,必要时pl/sql更好。
: 2. table statistic 有问题
: 3. 用telnet的人很多。

avatar
B*g
43
USE_NL(b) and USE_NL(b a) 一样, 见附件
first_rows 基本一样,就多一hint

【在 c*****d 的大作中提到】
: 嗯,这也是我想问的
: 能贴一下exec plan

avatar
w*r
44
bitmap index on the tablea?
also function based index on tableb..

【在 B*****g 的大作中提到】
: 请看附件。谢谢
: TAB_A 8M records
: TAB_B 0.2M records
: subquery TAB_B will return 1-5 rows for most of records in TAB_B(except
: around 20).
: 现在我要用 IN,即使sub里面只有一个return,至少10分钟还没有结束。要是用 =,
: 只要几秒钟。试过各种hint,都没能成功。暂时我把SQL改成了PL/SQL(loop
: subquery 里面),想知道只用SQL砸搞。
: Note: 由于公司政策,table/column名字不能公开。

avatar
B*g
45
only b-tree allowed

【在 w*r 的大作中提到】
: bitmap index on the tablea?
: also function based index on tableb..

avatar
m*d
46
tab_b subquery 需要花费一定时间,但这个不是主要问题,所以在table b上新建inde
x 帮助不大。 主要问题是join上花费太大了,具体来说。
1.tab_b 的statistic 有问题,前面你说了tab_b 返回也就几行,但execution plan 返
回 70多万行。这个是oracle 下一步xecution plan 选择错误的原因。
2.tab_b 返回只有几行,但oracle 基于前面的错误,选择了nest join( table a 作为
outer table) 或者 hash jon(在你用了ordered之后)。
你可以试着加加hint /*+ ordered use_nl(a) */ 或者/*use_nl(a)*/,再查看executi
on plan,直到oracle 把 table b作为nested join的 outer table 为止
你用“=”之所以会很快出来,是应为oracle把他作为一个filter,所以用不着nest joi
n/hash join,你看一下execution plan就知道了。

【在 B*****g 的大作中提到】
: only b-tree allowed
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。