Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

can anyone tell me who is faster? thanks!

1 réponse
Avatar
my909
1.--------->
////////////////////////////////////////////////////////////////////////////
///////////////
select
rtrim(Replace(Replace(cast(substring(A.NewsContent,0,8000) as
varchar(8000)), char(30), ''), char(13), '')) as NewsContent,
A.NewsID,A.NewsTitle
from News_Content A
where A.NewsID in
(select B.NewsID from News_Second_Class_Index_AE B
where B.NewsID in
( select C.NewsID from News_Keyword_Group_Index_6 C
where C.KeyWordID='11'))
////////////////////////////////////////////////////////////////////////////
//////////////////


2.---------->
////////////////////////////////////////////////////////////////////////////
////////////////////

select top 100 rtrim(Replace(Replace(cast(substring(A.NewsContent,0,8000) as
varchar(8000)), char(30), ''), char(13), ''))
as NewsContent,A.NewsID,A.NewsTitle From News_Content A
inner join News_Second_Class_Index_AE b on A.NewsID = B.NewsID
inner join News_Keyword_Group_Index_6 C on B.NewsID = C.NewsID
where C.KeyWordID = '11' order by A.NewsID desc

////////////////////////////////////////////////////////////////////////////
//////////////////////

can anyone tell me who is faster?

1 réponse

Avatar
lionelp
Hello,

2nd query is slower because:
the ORDER BY sorts all rows then stores them in a temporary space, then top
gets the first 100 rows of it.

1st query is a subset of the second one.

LionelP


"my909" wrote in message
news:
1.--------->



////////////////////////////////////////////////////////////////////////////
///////////////
select
rtrim(Replace(Replace(cast(substring(A.NewsContent,0,8000) as
varchar(8000)), char(30), ''), char(13), '')) as NewsContent,
A.NewsID,A.NewsTitle
from News_Content A
where A.NewsID in
(select B.NewsID from News_Second_Class_Index_AE B
where B.NewsID in
( select C.NewsID from News_Keyword_Group_Index_6 C
where C.KeyWordID='11'))



////////////////////////////////////////////////////////////////////////////
//////////////////


2.---------->



////////////////////////////////////////////////////////////////////////////
////////////////////

select top 100 rtrim(Replace(Replace(cast(substring(A.NewsContent,0,8000)


as
varchar(8000)), char(30), ''), char(13), ''))
as NewsContent,A.NewsID,A.NewsTitle From News_Content A
inner join News_Second_Class_Index_AE b on A.NewsID = B.NewsID
inner join News_Keyword_Group_Index_6 C on B.NewsID = C.NewsID
where C.KeyWordID = '11' order by A.NewsID desc




////////////////////////////////////////////////////////////////////////////
//////////////////////

can anyone tell me who is faster?