查询DISTINCT性能问题???

flers 2004-09-08 04:01:57
select distinct flight_date,
airways2code,
TBLB.Dep,
TBLB.dest,
awb_prefix + awb_no as awb,
flight_dep,
flight_dest,
TBLA.Weight as Cweight,
Piece,
Cargo_Block_ID,
TBLA.Commodity_Name,
TBLA.flight_no,
TBLD.ac_type,
TBLB.Freight,
TBLA.agent_id,
TBLB.weight as Aweight,
(TBLA.Weight / TBLB.weight) * TBLB.Freight as 航空运费,
company_SName
from tbl_cargobill as TBLA
left join (select awb_prefix + awb_no as awb,
Freight,
weight,
dep,
dest
from tbl_awb_basic) as TBLB
on TBLB.AWB = awb_prefix + awb_no
left join (select TBL_FLIGHT_ACTIVE.flight_no,
TBL_FLIGHT_ACTIVE.ac_type
from TBL_FLIGHT_ACTIVE) AS TBLD
ON TBLA.flight_no = TBLD.flight_no
left join (select agent_id,
company_SName
from tbl_agent TBLC) TBLC
on TBLA.agent_id = TBLC.agent_id
where (TBLA.flight_no is not null)
AND (flight_date between '2004-8-30' and '2004-8-30')
把distinct 去了要3秒,每个表7万条记录,但加上的话至少要6-8秒,而且distinct花的资源是85%有什么办法提高呢?
...全文
408 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
chinaandys 2004-09-08
  • 打赏
  • 举报
回复
多字段最好不用distinct.
用 group by 可以替待。
hisi 2004-09-08
  • 打赏
  • 举报
回复
distinct就是耗资源~,
用group by 可以替待, 但同样耗资源,没有办法。

27,580

社区成员

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

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