由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Database版 - Remove duplicate from oracle table
相关主题
how to write this query怎么去除duplicates
再问个 subquery的问题SQL question
请教一个SQL的问题新手请教:为什么这个Query不work
help about SQL for ACCESS服了,这就是我们QA和DBA的水平
SQL combine two tables into one table and add a new columnlist duplicators in one table
correlated subquery关于in的效率
求教个MS SQL的问题SQL求助
urgent help! insert value into tableaks a simple SQL question
相关话题的讨论汇总
话题: where话题: table话题: delete话题: name话题: select
进入Database版参与讨论
1 (共1页)
B*****g
发帖数: 34098
1
seems (1=3) > 2 > 4, why? how can 1=3? 谁给说说?
Thanks
col0 is unique
DELETE FROM table_name A
WHERE A.col0> ANY (SELECT B.col0 FROM table_name B
WHERE A.col1 = B.col1 AND A.col2 = B.col2)
DELETE FROM table_name A
WHERE A.col0 > (SELECT MIN(B.col0) FROM table_name B
WHERE A.col1 = B.col1 AND A.col2 = B.col2)
DELETE FROM table_name A
WHERE EXSITS (SELECT 1 FROM table_name B
WHERE A.col1 = B.col1 AND A.col2 = B.col2 AND A.col0 > B.col0
)
DELETE FROM
j*****n
发帖数: 1781
2
did not catch your point...
btw, I hate aggregated sql statements.
B*****g
发帖数: 34098
3
tuning。

【在 j*****n 的大作中提到】
: did not catch your point...
: btw, I hate aggregated sql statements.

M*****r
发帖数: 1536
4
你是说执行的时间长短?
看看execution plan?

【在 B*****g 的大作中提到】
: tuning。
c*****d
发帖数: 6045
5
4肯定是最差
3应该比1快,如果col2, col3上有index估计就差不多了
在toad里执行一下,贴个执行计划看看
别直接贴在bbs上,上传附件比较清晰一些

【在 B*****g 的大作中提到】
: seems (1=3) > 2 > 4, why? how can 1=3? 谁给说说?
: Thanks
: col0 is unique
: DELETE FROM table_name A
: WHERE A.col0> ANY (SELECT B.col0 FROM table_name B
: WHERE A.col1 = B.col1 AND A.col2 = B.col2)
: DELETE FROM table_name A
: WHERE A.col0 > (SELECT MIN(B.col0) FROM table_name B
: WHERE A.col1 = B.col1 AND A.col2 = B.col2)
: DELETE FROM table_name A

B*****g
发帖数: 34098
6
我说的(1=3)> 2 就是说的execeution plan。
我古狗了一下,说1,2,4的都很;没一个建议用exists的,所以我才这么问。可惜俺在
公司不能trace,下周把execution plan贴出来。

【在 c*****d 的大作中提到】
: 4肯定是最差
: 3应该比1快,如果col2, col3上有index估计就差不多了
: 在toad里执行一下,贴个执行计划看看
: 别直接贴在bbs上,上传附件比较清晰一些

s******e
发帖数: 493
7
just my guess. aggregation call min is more expensive.
According Tom Kyte, you should avoid built-in function call as much as you
can, since usually they mean more overhead, such as latches on cahe block,
etc.
s******e
发帖数: 493
8
my new found.
Just happened to read something that I believe it is a good explanation.
exists, any all, in are all operators rather than built-in functions.
Besides, the subquery using max, min which refer a column in parent query is
called "correlated query". For each row of parent query, it will be excuted
once. That should explain why using min is slower (overhead)
1 (共1页)
进入Database版参与讨论
相关主题
aks a simple SQL questionSQL combine two tables into one table and add a new column
高手请进correlated subquery
Re: How to find a duplicate record in Ac求教个MS SQL的问题
菜鸟问题,急urgent help! insert value into table
how to write this query怎么去除duplicates
再问个 subquery的问题SQL question
请教一个SQL的问题新手请教:为什么这个Query不work
help about SQL for ACCESS服了,这就是我们QA和DBA的水平
相关话题的讨论汇总
话题: where话题: table话题: delete话题: name话题: select