473,382 Members | 1,365 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Why would adding dbo. cause my function to run forever?

Lately I did a mass update on all our scripts and added
dbo. in front of all tables and other objects.

There is a function that returns a table and the function is
I think 300 lines. There are a lot of UNIONs, EXISTS,
NOT EXISTS, etc...

Anyhow there's a single place where if i add dbo. in front
of the table this function which is being called from an SP,
when i run the SP from the QA or from the ASP application
it runs forever. As soon as i remove the dbo. again it runs
in 6-8 seconds. Here's the thing this same table reference exists
a few lines below in the 2nd UNION for example and
having a dbo. in front doesn't cause any problems.

Even more confusing if i add Databasename.dbo.TableName
and run it again, i don't run into any problem.
So it's almost like if i specify dbo. in front of the table, somehow
SQL Server or our code is getting lost and searching for this
table in other databases?

Has anyone run or seen such a problem?

I am sure I can make changes to the code and end up
writing a different code but before I make changes I would
like to find out more about my mystery problem.

I am running SQL 2000 SP4 and the same problem occured
on two different machines. Win 2000 Pro and Win 2000 Server.

Any ideas, suggestions?

Thank you
Jan 13 '06 #1
4 1702
serge (se****@nospam.ehmail.com) writes:
Anyhow there's a single place where if i add dbo. in front
of the table this function which is being called from an SP,
when i run the SP from the QA or from the ASP application
it runs forever. As soon as i remove the dbo. again it runs
in 6-8 seconds. Here's the thing this same table reference exists
a few lines below in the 2nd UNION for example and
having a dbo. in front doesn't cause any problems.
I assume that we can rule out that there are two tables with different
owners, and you are logged in as that owner when you try this? Of course,
since:
Even more confusing if i add Databasename.dbo.TableName
and run it again, i don't run into any problem.


it's not very likely at all.

But I'm afraid I don't have very many ideas. Did you study the query
plan to see if they were identical in both cases?

--
Erland Sommarskog, SQL Server MVP, es****@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
Jan 13 '06 #2
> But I'm afraid I don't have very many ideas.

I wanted to find out if someone knew or had encountered this
weird problem or may have heard it as a SQL bug or something.
Basically I was hoping that this was a known issue and there
was a simple explanation to it.
Did you study the query plan to see if they were identical in
both cases?


It was a big plan that I had waited for around 35 minutes before I
got it. There were I think 2 statements of INSERT to a #temp table
taking about 32% each so that seemed to be the big overhead in the
execution plan.

This problem is very intriguing. Yesterday I ran your version of
sp_lock but I don't really know how to interpret sp_lock etc...
I'll have to read a couple of chapters on locking and spend a
number of hours to learn this stuff, experiment and see what
I'll manage to learn out of this.

I am sure it will be painful but rewarding as I'll get a chance
to learn about locking and much more.

If I do end up finding any interesting information I'll post it here.

Thanks Erland.

Jan 14 '06 #3
serge (se****@nospam.ehmail.com) writes:
I wanted to find out if someone knew or had encountered this
weird problem or may have heard it as a SQL bug or something.
Basically I was hoping that this was a known issue and there
was a simple explanation to it.
Unfortunately, I have never heard of this before. It sonds very strange.
It was a big plan that I had waited for around 35 minutes before I
got it. There were I think 2 statements of INSERT to a #temp table
taking about 32% each so that seemed to be the big overhead in the
execution plan.


A tip is to use SET STATISTICS_PROFILE ON. This gives you output in
text form, that you save to disk. Run this on both versions, and then
use Beyond Compare (http://www.scootersoftware.com) to compare the
output. Beyond Compare is good for this, becausee it produces diffs
on character level.


--
Erland Sommarskog, SQL Server MVP, es****@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
Jan 14 '06 #4
> Unfortunately, I have never heard of this before. It sonds very strange.

Today when I went to work I saw the developer of this file had
updated the code and I noticed the tablename that was causing
my problem was removed. The statement was part of a
EXISTS or NOT EXISTS statement and when I quickly looked
at what was removed and replaced with, I believe the table that
was causing the problem was in the original SELECT statement
before the EXISTS or NOT EXISTS condition.
Anyhow I have kept the database and the problem as a copy
and if I do find the time in the near future I will try to troubleshoot
it further.
It was a big plan that I had waited for around 35 minutes before I
got it. There were I think 2 statements of INSERT to a #temp table
taking about 32% each so that seemed to be the big overhead in the
execution plan.
A tip is to use SET STATISTICS_PROFILE ON. This gives you output in
text form, that you save to disk. Run this on both versions, and then
use Beyond Compare (http://www.scootersoftware.com) to compare the
output. Beyond Compare is good for this, becausee it produces diffs
on character level.


Very good idea I'll keep this mind to compare execution plans instead
of going through long graphical execution plans.

Thanks again.

Jan 17 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Gabe | last post by:
Please see: http://www.showorders.com/test3.asp The code generating the page is as follows: testdate = "1/29/2003 1:00:00 PM" while count <> 5 testdate = dateadd("n",15,testdate)...
4
by: OJ | last post by:
Hi, This works to maximize the window, but wants to load yahoo locally : C:\WINDOWS\Desktop\www.yahoo.com <html> <script type="text/javaScript"> <!-- function test() { qwe =...
20
by: David | last post by:
I have a one-line script to add an onunload event handler to the body of the document. The script is as follows: document.getElementsByTagName("BODY").onunload=function s() {alert("s")} Now...
2
by: Clayton Hamilton | last post by:
I have a DataGrid on a webform bound to a Datasource and can successfully use <ItemTemplate> to create edit/update/cancel functionality for user maintenance of data. I use separate logic to delete...
3
by: Ankit Aneja | last post by:
I have a strange situation and I have no idea how to solve this. Its a Recruitment Search Page,in the Admin Page, for every button click event the Admin Person has to create a checkbox on the users...
6
by: Juan Pedro Gonzalez | last post by:
I wanted to add a Combobox to a toolbar... Kind of the look you get on VisualStudio's toolbar. I've been able to find some VB 6 samples, but the placeholder option is no longer available for...
2
by: Martin Eckart | last post by:
Hello, I have built a Hello World Web Service using Visual Studio 2005 and .NET 2.0 on machine A. Setting up a Web Site on machine B and adding a web reference to that WS works fine, without any...
2
by: ChrisCicc | last post by:
Hi All, I got a real doozy here. I have read hundreds upon hundreds of forum posts and found numerous others who have replicated this problem, but have yet to find a solution. Through testing I have...
8
by: Hugh Oxford | last post by:
I know I can force a variable passed to a function to be an object of class bar eg function foo(bar $bar_object) { //code }
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.