高手请进:关于视图[内包含派生表]索引的问题!

Dong 2005-10-30 12:44:34
视图比较复杂,自定义了很多的函数,函数表,当然了,包含有派生表的问题[另外其它也搞了很多的派生表]!!没有办法,这是公司要我做的任务,任务是加快对视图的查询速度,我在在试图里建立不了索引![表5--8万记录,一般5万]


问题1:如何在一个包含有派生表的视图里加索引??难道死路一条??

问题2:如果不可以在一个带有派生表的试图里加索引,那么该怎样才可以加快试图的查询能力??

------------------------------------------------------------------
试图 SQL
select
。。。。。太长影响看问题,删除省烈
from
((select * from GetSpringboard() group by ID,Springboard)[A],
(select * from GetCHboard() group by ID,CHboard)[B]
where A.ID=B.ID)[A],
(select * from GetDestination() group by ID,Destination)[B],
(select * from GetRDate())[C],
(select * from GetTDate())[D],
(* from provide)[E],
(select * from GetPrice())[G]
where A.ID = B.ID
and A.ID = C.ID
and A.ID = D.ID
and A.ID = E.ID
and A.ID = G.ID
--------------------------------------------------------------------

问题3:(select * from GetRDate())[C],这应该是属于派生表了吧?

问题4:((select * from GetSpringboard() group by ID,Springboard)[A],
(select * from GetCHboard() group by ID,CHboard)[B]
where A.ID=B.ID)[A],这个肯定是派生表了吧??
...全文
224 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
新鲜鱼排 2005-11-02
  • 打赏
  • 举报
回复
http://www.zj35.net.cn/printpage.asp?BoardID=11&ID=123
看看能不能優化一下存儲過程。
新鲜鱼排 2005-11-02
  • 打赏
  • 举报
回复
樓主說的派生表是不是臨時表的意思??
netcoder 2005-11-02
  • 打赏
  • 举报
回复
派生表?
楼主解释一下吧!
Dong 2005-11-02
  • 打赏
  • 举报
回复
netcoder(朱二), dutguoyi(新鲜鱼排)
---------------------------
派生表和临时表是不同的,派生表在处理上(内部/内存管理上)和临时表是有点区别的,其他一样.
我是这样理解的,派生表只是一个"过程"中产生的表
huang2005 2005-11-01
  • 打赏
  • 举报
回复
视图里可以建立索引吗?
可以说一下什么是派生表吗?
我是新生!
谢谢 了
prcgolf 2005-10-31
  • 打赏
  • 举报
回复
up
zxbyhcsdn 2005-10-31
  • 打赏
  • 举报
回复
不用视图,因为你没查询一次视图都要查询出所有的纪录,然后再在纪录中找出满足你条件的纪录。数据量大了慢的很

写一个存储过程
然后根据你传入的条件,

用动态Sql返回结果

把下面的这些写道动态Sql中,和你传入的条件一起用Exec执行,然后返回结果

from
((select * from GetSpringboard() group by ID,Springboard)[A],
(select * from GetCHboard() group by ID,CHboard)[B]
where A.ID=B.ID)[A],
(select * from GetDestination() group by ID,Destination)[B],
(select * from GetRDate())[C],
(select * from GetTDate())[D],
(* from provide)[E],
(select * from GetPrice())[G]
where A.ID = B.ID
and A.ID = C.ID
and A.ID = D.ID
and A.ID = E.ID
and A.ID = G.ID
lisiyong 2005-10-31
  • 打赏
  • 举报
回复
怎样才可以加快试图的查询能力??

个人认为和表查询优化差不多....
lisiyong 2005-10-31
  • 打赏
  • 举报
回复
UP

27,579

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 应用实例
社区管理员
  • 应用实例社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧