由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Database版 - 高手请指点: How to query specific data in all columns efficiently
相关主题
Oracle Group and Index questionJoin optimization
SQL query 一问请教 sql server index问题
怎么reference temp table的columnSQL的index到底派什么用?
SQL 2008 Create Index vs Rebuild Index (Alter Index)请教三个Key的property,
SQL 2000 create index 問題这个cassandra paging的解决方案怎么样? (转载)
database triggerswant to import CSV file to mysql, so I have to create a table first?
两个列联合作Primary Key,还需要单独建index吗?请教sql server temptable # 和 ##
query: in sql server 2005请教oracle select top 10 from ... order by desc
相关话题的讨论汇总
话题: exptable话题: create话题: index话题: idx话题: float
进入Database版参与讨论
1 (共1页)
t***u
发帖数: 368
1
blow query is VERY slow: > 15 mins, any suggestions appreciated !!
@tempTable ~ 20k data
#ExpTable ~ 500k data
declare @tempTable table
(

data_id int,

Q float,

Qtype int
)
create table #ExpTable
(
data_id int,

B1 float,
B2 float,
B3 float,
B4 float,
B5 float,

B6 float,
B7 float,
B8 float,
B9 float,
B10 float
)



CREATE INDEX IDX_1 ON #ExpTable(B1)
CREATE INDEX IDX_2 ON #ExpTable(B2)
CREATE INDEX IDX_3 ON #ExpTable(B3)
CREATE INDEX IDX_4 ON #ExpTable(B4)
CREATE INDEX IDX_5 ON #ExpTable(B5)

CREATE INDEX IDX_6 ON #ExpTable(B6)
CREATE INDEX IDX_7 ON #ExpTable(B7)
CREATE INDEX IDX_8 ON #ExpTable(B8)
CREATE INDEX IDX_9 ON #ExpTable(B9)
CREATE INDEX IDX_10 ON #ExpTable(B10)
select

a.data_id ,
b.Q,
b.QType

from #ExpTable a
,
(select distinct Q, QType from @tempXTable) b
where
(
a.B1 = b.Q or a.B2 = b.Q or a.B3 = b.Q or a.B4 = b.Q or a.B5 = b.Q
or
a.B6 = b.Q or a.B7 = b.Q or a.B8 = b.Q or a.B9 = b.Q or
a.B10 = b.Q
)
c****s
发帖数: 10
2

try this:
select a.data_id, b.q, b.qtype from a inner join b
on b.q = a.b1 or b.q = a.b2 or b.q = a.b3 or b.q = a.b4 or .....
1 (共1页)
进入Database版参与讨论
相关主题
请教oracle select top 10 from ... order by descSQL 2000 create index 問題
如何在数据库中进行复杂查询, 但不把中间结果放到程序内存database triggers
补贴上次面试题两个列联合作Primary Key,还需要单独建index吗?
Late afternoon 腦不好使query: in sql server 2005
Oracle Group and Index questionJoin optimization
SQL query 一问请教 sql server index问题
怎么reference temp table的columnSQL的index到底派什么用?
SQL 2008 Create Index vs Rebuild Index (Alter Index)请教三个Key的property,
相关话题的讨论汇总
话题: exptable话题: create话题: index话题: idx话题: float