由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Database版 - 问一个Oralce index的问题
相关主题
[合集] 问一个Oralce index的问题CINAOUG/CINASSUG MySQL 2013讲座
关于in的效率请问MySQL 可以快速处理table有1亿条数据么?
新学mysql,请教一个时间估计Oracle 问 题 请 诸 位 大 侠 指 教, 急 急 急!!!
mysql rebuild index very slowINDEX请教
MYSQL 的LOG SIZE怎么在不停 变大[转载] 求教数据库的query optimization 工作的面试
mysql 如何更新一个表的index啊?两个列联合作Primary Key,还需要单独建index吗?
MySQL 5.0 cluster questionJoin optimization
问个牛人才能解答的问题,关于mysql的内存如何决定index
相关话题的讨论汇总
话题: index话题: name话题: last话题: upper话题: select
进入Database版参与讨论
1 (共1页)
y********o
发帖数: 2565
1
比如说:
select last_name from employees where upper(last_name) like 'JO%';
有没有创建一个index在last_name上,我们肉眼根本看不出区别的吧,是不是?
t*****g
发帖数: 1275
2
select * from all_indexes where table_name = EMPLOYEES
y********o
发帖数: 2565
3
I don't know what you are suggesting, though.
I did find the index I created in all_indexes:
OWNER INDEX_NAME INDEX_TYPE TABLE_OWNER TABLE_NAME
q**1
发帖数: 193
4
MySQL一般用explain
explain select last_name from employees where ******;
会输出一个表,可以看出你的 SQL 命令到底有没有用到indexes

【在 y********o 的大作中提到】
: 比如说:
: select last_name from employees where upper(last_name) like 'JO%';
: 有没有创建一个index在last_name上,我们肉眼根本看不出区别的吧,是不是?

y********o
发帖数: 2565
5
噢,这个我知道,在Oracle里面做:
set autotrace on explain
我可以看到oracle 确实用了lastnameindex:
y********o
发帖数: 2565
6
其实我不太懂oracle的这个 execution plan.

(
2
2

【在 y********o 的大作中提到】
: 噢,这个我知道,在Oracle里面做:
: set autotrace on explain
: 我可以看到oracle 确实用了lastnameindex:

s**o
发帖数: 584
7
You actually don't have any benefit of index by using 'like'.
If you use select * from employees where upper(last_name) like 'JO%';
It will be gaurantee a full table access.
In your statement,
select last_name from employees where upper(last_name) like 'JO%';
Most likely, if you have an index built on last_name, you will have full
index scan which doesn't do any better performance.
avoid to use 'like' unless you absolutely have to or the table is small and
it's definitely not scalable in the fut

【在 y********o 的大作中提到】
: 比如说:
: select last_name from employees where upper(last_name) like 'JO%';
: 有没有创建一个index在last_name上,我们肉眼根本看不出区别的吧,是不是?

y********o
发帖数: 2565
8
So, we will only benefit from index if we use the equal operator (=), right?

and

【在 s**o 的大作中提到】
: You actually don't have any benefit of index by using 'like'.
: If you use select * from employees where upper(last_name) like 'JO%';
: It will be gaurantee a full table access.
: In your statement,
: select last_name from employees where upper(last_name) like 'JO%';
: Most likely, if you have an index built on last_name, you will have full
: index scan which doesn't do any better performance.
: avoid to use 'like' unless you absolutely have to or the table is small and
: it's definitely not scalable in the fut

q**1
发帖数: 193
9
I think the main problem is the upper() function, since you indexed
the value of "last_name" instead of the value of upper(last_name).
"like" clause should be OK. coz you use "A%" instead of "%A" or
"%A%", you can use index anyway.
my 2 cents,

right?

【在 y********o 的大作中提到】
: So, we will only benefit from index if we use the equal operator (=), right?
:
: and

y********o
发帖数: 2565
10
Saho, your 2 cents are in order.

【在 q**1 的大作中提到】
: I think the main problem is the upper() function, since you indexed
: the value of "last_name" instead of the value of upper(last_name).
: "like" clause should be OK. coz you use "A%" instead of "%A" or
: "%A%", you can use index anyway.
: my 2 cents,
:
: right?

q**1
发帖数: 193
11
that is for MySQL, I dont know Oracle..They may have very
different indexing strategies.

【在 y********o 的大作中提到】
: Saho, your 2 cents are in order.
s**o
发帖数: 584
12
you are right on that. 'A%' is a little bit special, you will get a index
range scan. The statement give him an index full scan due to "Select last_
name from ...". It will give a index range scan if the upper() function
index is built or the upper() clause is removed.

【在 q**1 的大作中提到】
: I think the main problem is the upper() function, since you indexed
: the value of "last_name" instead of the value of upper(last_name).
: "like" clause should be OK. coz you use "A%" instead of "%A" or
: "%A%", you can use index anyway.
: my 2 cents,
:
: right?

1 (共1页)
进入Database版参与讨论
相关主题
如何决定indexMYSQL 的LOG SIZE怎么在不停 变大
怎样解决 Index for NULL valuemysql 如何更新一个表的index啊?
一个很平常的问题MySQL 5.0 cluster question
求救,这个更新如何写?问个牛人才能解答的问题,关于mysql的内存
[合集] 问一个Oralce index的问题CINAOUG/CINASSUG MySQL 2013讲座
关于in的效率请问MySQL 可以快速处理table有1亿条数据么?
新学mysql,请教一个时间估计Oracle 问 题 请 诸 位 大 侠 指 教, 急 急 急!!!
mysql rebuild index very slowINDEX请教
相关话题的讨论汇总
话题: index话题: name话题: last话题: upper话题: select