由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Database版 - 如何决定index
相关主题
问个Index的问题Any faster way to retrieve only one record?
Common Table Expression 问题SQL server stored procedure 求助
什么时候不用索引indexing就是设置primary key吗?
被人鄙视了请教 sql server index问题
测一下你的t-sql 功力SQL 2008 Create Index vs Rebuild Index (Alter Index)
SSRS report failing to display dataset stringSQL 2000 create index 問題
Oracle Group and Index questionurgent help! insert value into table
SQL Server 2005: How to hash a column?问一个Oralce index的问题
相关话题的讨论汇总
话题: index话题: table话题: when话题: 10k话题: userid
进入Database版参与讨论
1 (共1页)
f*****e
发帖数: 5177
1
non-cluster index,每增加一个column,都会让search的cost减少,但是I/D/U的cost
增加。
如何找到这个平衡点呢?
Let's say, I have a table to log client activities.
CREATE TABLE ClientLog
(
UserID INT,
TransID INT,
MachineName NVARCHAR(128)
Time DATETIME
)
UserID and TransID are unique non-clustered index.
When a transaction starts, a log is inserted. When a transaction is closed,
the log is deleted.
Now, I am thinking if I need to create another non-cluster index to include
UserID, TransID and MachineName because most of Delete an
B*****g
发帖数: 34098
2
我觉得你这个case显然I是最重要的。你能有多少时间去S这个log table。俺们公司的l
ogtable一个index都没有,呵呵。

cost
,
include
index,
03.

【在 f*****e 的大作中提到】
: non-cluster index,每增加一个column,都会让search的cost减少,但是I/D/U的cost
: 增加。
: 如何找到这个平衡点呢?
: Let's say, I have a table to log client activities.
: CREATE TABLE ClientLog
: (
: UserID INT,
: TransID INT,
: MachineName NVARCHAR(128)
: Time DATETIME

c*****d
发帖数: 6045
3
如果是When a transaction starts, a log is inserted. When a transaction is
closed, the log is deleted.
这个表应该很小
如果表不大,完全没必要创建Index
a*******s
发帖数: 324
4
how to define a table is big or not big?
How about 10k records?
I tested a table with 10k records w/o index for joining purpose, seems they
have the same performance.

【在 c*****d 的大作中提到】
: 如果是When a transaction starts, a log is inserted. When a transaction is
: closed, the log is deleted.
: 这个表应该很小
: 如果表不大,完全没必要创建Index

a*******t
发帖数: 891
5
are you sure when you using the table with index, the query is indeed using
the index seek instead of table scan?

they

【在 a*******s 的大作中提到】
: how to define a table is big or not big?
: How about 10k records?
: I tested a table with 10k records w/o index for joining purpose, seems they
: have the same performance.

B*****g
发帖数: 34098
6
一般大。

they

【在 a*******s 的大作中提到】
: how to define a table is big or not big?
: How about 10k records?
: I tested a table with 10k records w/o index for joining purpose, seems they
: have the same performance.

c*****d
发帖数: 6045
7
10k的表只能算是中等偏小的表
不过我对你的试验很感兴趣,你是10k table join 10k table吗?
10k vs. 100m性能应该有很大区别呀

they

【在 a*******s 的大作中提到】
: how to define a table is big or not big?
: How about 10k records?
: I tested a table with 10k records w/o index for joining purpose, seems they
: have the same performance.

B*****g
发帖数: 34098
8
如果table没有statistic,会不会有影响?

【在 c*****d 的大作中提到】
: 10k的表只能算是中等偏小的表
: 不过我对你的试验很感兴趣,你是10k table join 10k table吗?
: 10k vs. 100m性能应该有很大区别呀
:
: they

a*******s
发帖数: 324
9
table1 10k
id not index or index
table2 100m
id not indexed
where table1.id = table2.id
They are almost the same. Database is postgre. Not sure if postgre will
index the table1.id in the memory.

【在 c*****d 的大作中提到】
: 10k的表只能算是中等偏小的表
: 不过我对你的试验很感兴趣,你是10k table join 10k table吗?
: 10k vs. 100m性能应该有很大区别呀
:
: they

c*****d
发帖数: 6045
10
没用过postgre
postgre里能看执行计划吗,看看有没有使用索引,哪个是driving table

【在 a*******s 的大作中提到】
: table1 10k
: id not index or index
: table2 100m
: id not indexed
: where table1.id = table2.id
: They are almost the same. Database is postgre. Not sure if postgre will
: index the table1.id in the memory.

相关主题
SSRS report failing to display dataset stringAny faster way to retrieve only one record?
Oracle Group and Index questionSQL server stored procedure 求助
SQL Server 2005: How to hash a column?indexing就是设置primary key吗?
进入Database版参与讨论
c*****d
发帖数: 6045
11
在Oracle 8i,9i里面,肯定有影响
没有statistic,engine无法决定cost,只能用rbo

【在 B*****g 的大作中提到】
: 如果table没有statistic,会不会有影响?
a*******s
发帖数: 324
12
just test.
postgre will sort the table1.id first, the rest is the same.
Both scan against the small table id.

【在 c*****d 的大作中提到】
: 没用过postgre
: postgre里能看执行计划吗,看看有没有使用索引,哪个是driving table

k********e
发帖数: 702
13
postgres也能看执行计划
另外,statistics非常重要

【在 c*****d 的大作中提到】
: 没用过postgre
: postgre里能看执行计划吗,看看有没有使用索引,哪个是driving table

c*****d
发帖数: 6045
14
hehe,才发现ambitious理解错我的意思了
“不过我对你的试验很感兴趣,你是10k table join 10k table吗?
10k vs. 100m性能应该有很大区别呀”
我是说如果1个10k table join 另一个10k table
有index,时间是10k
没有index,时间是100m,性能有很大区别
这是我在oracle上做出的结果,
==no index,nest loop join=====
call count cpu elapsed disk query current rows
c*****d
发帖数: 6045
15
刚才的试验中,如果有statistic,不管有没有索引,Oracle都使用hash join
== with index ================================
call count cpu elapsed disk query current rows
c*****d
发帖数: 6045
16
编辑了半天,累死我了
这个bbs怎么贴代码才不会出乱码呢?
B*****g
发帖数: 34098
17
co-ask

【在 c*****d 的大作中提到】
: 编辑了半天,累死我了
: 这个bbs怎么贴代码才不会出乱码呢?

u******u
发帖数: 595
18
There is NO fixed standard to use index or not.
As the data keep changing, you may find your old query becomes slow. Adding
a index will help your query in most cases.
However, too many indexed columns will NOT help your DML (inert/update/
delete).
Need watch the performance to see whether the index is helpful or not.
Thanks!
美国老土
1 (共1页)
进入Database版参与讨论
相关主题
问一个Oralce index的问题测一下你的t-sql 功力
Help on Sql server huge table performanceSSRS report failing to display dataset string
MS T-SQL 问题Oracle Group and Index question
请教:'now' 的时间是怎么实现的SQL Server 2005: How to hash a column?
问个Index的问题Any faster way to retrieve only one record?
Common Table Expression 问题SQL server stored procedure 求助
什么时候不用索引indexing就是设置primary key吗?
被人鄙视了请教 sql server index问题
相关话题的讨论汇总
话题: index话题: table话题: when话题: 10k话题: userid