Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Performance - my SP needs some
Message
From
26/09/2002 23:42:02
 
 
To
26/09/2002 21:33:42
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Miscellaneous
Thread ID:
00705044
Message ID:
00705067
Views:
19
>Hi All,
>
>I have a table that contains about 2 million records and has a full text index built on two varchar fields (lengths = 100 and 300, respectively).
>

This can't be done with ONE select. Why go throught the recordset and indexes twice?

>Any ideas on how to make this SP run faster?
>(it's now taking about 5 seconds to run)
>
>
>
>CREATE PROCEDURE __get_links
> @intPage int = 1,
> @strSearch varchar(200) = 'free email',
> @strCommonImages varchar(100) = '/images'
>AS
>
>BEGIN
> SET NOCOUNT ON
> SET @strSearch = '"' + @strSearch + '"'
> DECLARE @intStart integer
> SET @intStart = (@intPage * 10) - 10
> CREATE TABLE #temp ( recID int IDENTITY (1,1), link_id int, link_title varchar (100), link_url varchar (400), link_description varchar (300), priority int, rank int )
> INSERT INTO #temp (link_id, link_title, link_url, link_description, priority, rank)
>  SELECT a.link_id, a.link_title, a.link_url, a.link_description, a.link_priority, b.rank
>  FROM live.dbo._links a INNER JOIN
>  CONTAINSTABLE (live.dbo._links, *, @strSearch, 100 ) b
>  ON a.link_id = b.[KEY]
>  ORDER BY b.rank DESC, a.link_priority DESC
>  OPTION (KEEPFIXED PLAN)
>
>
> -- Get our 10 records
>SELECT TOP 10
>      ('<TR><TD width=99% align=left><A class=blueLink8 href=javascript:sendLink("' +CAST(link_id as varchar(10))+ '");><U><B>') as col_1,
>      'col_2' =
>      CASE
>         WHEN LEN(link_title) > 67 THEN LEFT(link_title,67) + '...</B></U></A><BR><FONT class=fntDarkBlue8>'
>         ELSE link_title + '</B></U></A><BR><FONT class=fntDarkBlue8>'
>      END,
>      'col_3' =
>      CASE
>         WHEN LEN(link_description) > 180 THEN LEFT(LEFT(link_description, CHARINDEX('TE_ADULT',link_description)-1),177) + '...'
>         ELSE LEFT(link_description, CHARINDEX('TE_ADULT',link_description)-1)
>      END,
>      ('</FONT><BR></TD><TD width=120><IMG border=0 src=' +@strCommonImages+ '/clear.gif width=120 height=1></TD></TR>') as col_4,
>      ('<TR><TD colspan=3><IMG border=0 src=' +@strCommonImages+ '/clear.gif width=100% height=10></TD></TR>') as col_5
>   FROM #temp WHERE recID > @intStart
> DROP TABLE #temp
>END
>
>
>
>Thanks for any help....
>Mike
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform