Unix Technical Forum

sp_fkeys stored procedue is very slow

This is a discussion on sp_fkeys stored procedue is very slow within the SQL Server forums, part of the Microsoft SQL Server category; --> I am trying to find the tables and columns that depends on 'table1' sp_fkeys @pktable_name='table1' and this takes about ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-29-2008, 08:25 PM
keyvez@gmail.com
 
Posts: n/a
Default sp_fkeys stored procedue is very slow

I am trying to find the tables and columns that depends on 'table1'

sp_fkeys @pktable_name='table1'

and this takes about eight seconds, whereas if I run it for finding all
tables and columns that 'table1' depends on

sp_fkeys @fktable_name='table1'

this only takes a second.

How can I speed up the first stored procedure execution?

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-29-2008, 08:25 PM
Erland Sommarskog
 
Posts: n/a
Default Re: sp_fkeys stored procedue is very slow

(keyvez@gmail.com) writes:
> I am trying to find the tables and columns that depends on 'table1'
>
> sp_fkeys @pktable_name='table1'
>
> and this takes about eight seconds, whereas if I run it for finding all
> tables and columns that 'table1' depends on
>
> sp_fkeys @fktable_name='table1'
>
> this only takes a second.
>
> How can I speed up the first stored procedure execution?


Are there many tables in the database?

I'm afraid there is not that much you could do. You could of course
script the database from the master database, and play around with a
copy of the procedure, to see if you can make it go faster. One idea
there would be to replace the temp tables with table variables. Tracing
the procedure in Profile would of course also be necessary to see where
the time is spent.


--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-29-2008, 08:32 PM
keyvez@gmail.com
 
Posts: n/a
Default Re: sp_fkeys stored procedue is very slow

I was having the same problem for months, so I decided to modify the
sys.sp_fkeys stored procedure and I found the problem, if you want a
fix, here's my modification

http://www2.keyvez.com:82/?q=node/12

keyvez@gmail.com wrote:
> I am trying to find the tables and columns that depends on 'table1'
>
> sp_fkeys @pktable_name='table1'
>
> and this takes about eight seconds, whereas if I run it for finding all
> tables and columns that 'table1' depends on
>
> sp_fkeys @fktable_name='table1'
>
> this only takes a second.
>
> How can I speed up the first stored procedure execution?


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 02:43 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com