Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Performance - my SP needs some
Message
From
29/09/2002 15:08:23
 
 
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Miscellaneous
Thread ID:
00705044
Message ID:
00705681
Views:
13
>Could you post the execution plan? The order of the items is important.
>
>-Mike
>

Hi Mike,

Here is execution plan and the associated costs:
 - INSERT: (Insert Into #temp)  --  Cost 0% 
 - TABLE INSERT/Insert: (SET:Insert rows)  --  Cost 0% 
 - TOP: (selecting first few rows based on sort)  --  Cost 0% 
 - COMPUTE SCALAR: (getidentity)  --  Cost 1% 
 - SORT: (order by)  --  Cost 0% 
 - COMPUTE SCALAR: (convert)  --  Cost 0% 
 - FILTER: (where)  --  Cost 0% 
 - BOOKMARK LOOKUP: (bookmark lookup)  --  Cost 62% 
 - NESTED LOOP: (inner join)  --  Cost 0% 
 - REMOTE SCAN: (contains clause)  --  Cost 34% 
 - INDEX SEEK: (object:ordered)  --  Cost 3% 
And here is the SP:
BEGIN
 SET NOCOUNT ON
 DECLARE @intPage int
 SET @intPage = 1
 DECLARE @strSearch varchar(50)
 SET @strSearch = '"free email" AND IS_ADULT_0 AND IS_ENABLED_1'
 DECLARE @strCommonImages varchar(100)
 SET @strCommonImages  = '\images'
 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 odp_live.dbo._links_live a INNER JOIN
  CONTAINSTABLE (odp_live.dbo._links_live, *, @strSearch, 100 ) b
  ON a.link_id = b.[KEY]
  WHERE a.link_enabled=1
  ORDER BY b.rank DESC, a.link_priority DESC
  OPTION (KEEPFIXED PLAN)

 DECLARE @intTotalRecords int
 SET @intTotalRecords = (SELECT COUNT(*) FROM #temp)
 SELECT TOP 10 @intTotalRecords as link_total, link_id, 'link_title' =
      CASE
         WHEN LEN(link_title) > 67 THEN LEFT(RTRIM(link_title),67) + '...'
         ELSE link_title
      END, 
      'link_description' = 
      CASE
         --WHEN LEN(link_description) > 180 THEN LEFT(LEFT(RTRIM(link_description), CHARINDEX('IS_ADULT',RTRIM(link_description))-1),177) + '...'
         --ELSE LEFT(RTRIM(link_description), CHARINDEX('IS_ADULT',RTRIM(link_description))-1)
         WHEN LEN(link_description) > 180 THEN LEFT(LEFT(link_description, CHARINDEX('IS_ADULT',link_description)-1),177) + '...'
         ELSE LEFT(link_description, CHARINDEX('IS_ADULT',link_description)-1)
      END
 FROM #temp WHERE recID > @intStart OPTION (KEEPFIXED PLAN)
 DROP TABLE #temp
END
Thanks again for your help on this and many other matters you have helped on....

Mike
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform