![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I have an MS SQL db holding distributor information for my client, consisting of domestic and intl distributors. From an asp page, the user is prompted to input their country. When a domestic location is chosen, things work smoothly. When an international location is chosen, the asp eventually times out and returns an ASP 0113 error. For several months, the international side worked fine. Using my development db, things work fine. This makes me think something inconsistent could have entered the (prod) data and is causing it to spin. This query should return a list of 1 or more distributors matching a locale. It now returns one match, and subsequent entries are replaced with the ASP 0113 error. |
#3
| |||
| |||
|
|
(RodStron... (AT) gmail (DOT) com) writes: I have an MS SQL db holding distributor information for my client, consisting of domestic and intl distributors. From an asp page, the user is prompted to input their country. When a domestic location is chosen, things work smoothly. When an international location is chosen, the asp eventually times out and returns an ASP 0113 error. For several months, the international side worked fine. Using my development db, things work fine. This makes me think something inconsistent could have entered the (prod) data and is causing it to spin. This query should return a list of 1 or more distributors matching a locale. It now returns one match, and subsequent entries are replaced with the ASP 0113 error. There are two queries. The first one returns, the second times out? (By the way, the timeout is entirely a client-side thing. SQL Server does mind if you wait forever.) How big is the distributors_detail table? To determine this run: exec sp_spaceused distributors_detail, TRUE I can see two possibilities: one is that the table is very big, and takes a long time to scan. Because that much is clear: the way the query, there is no index that can be used efficiently. But if the table is small, that should not be an issue. The other possibility is blocking. You can determine this with sp_who2. Keep an eye on the Blk column. If there is a value, it means that the spid in the Blk column blocks the spid on that row. If that is your web request, you have the culprit. Probably you should kill the blocker, but you should probably try to find out what it is. -- Erland Sommarskog, SQL Server MVP, esq... (AT) sommarskog (DOT) se Books Online for SQL Server 2005 athttp://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books... Books Online for SQL Server 2000 athttp://www.microsoft.com/sql/prodinfo/previousversions/books.mspx |
#4
| |||
| |||
|
|
The two queries are pertaining to domestic vs intl. It does a lookup for a country code, and case 1 of domestic, case 2 of international. The query I copied in here is the intl. Both queries run from the same table, but searching the domestic entries runs smoothly. Running the sp_spaceused returns: name rows reserved data index_size unused distributors_detail 973 440 KB 368 KB 56 KB > 16 KB |
|
sql = sql& "isNull(cust_code_3,'') in('', 'CH') AND " sql = sql & " or LEFT(cust_no, CHARINDEX('-', cust_no) - 1) = '"& trim(arrDist_id_physical(iIntern)) &"'" sql = sql& "LEFT(distributors_detail.cust_no, CHARINDEX('-', distributors_detail.cust_no) - 1) IN (" |
#5
| |||
| |||
|
|
(RodStron... (AT) gmail (DOT) com) writes: The two queries are pertaining to domestic vs intl. It does a lookup for a country code, and case 1 of domestic, case 2 of international. The query I copied in here is the intl. Both queries run from the same table, but searching the domestic entries runs smoothly. Running the sp_spaceused returns: name rows reserved data index_size unused distributors_detail 973 440 KB 368 KB 56 KB > 16 KB Less than a megabyte. The poor search conditions should not be an issue. But when I reviewed your original post, I notice that the SQL that is generated is not correct. There is this: sql = sql& "isNull(cust_code_3,'') in('', 'CH') AND " sql = sql & " or LEFT(cust_no, CHARINDEX('-', cust_no) - 1) = '"& trim(arrDist_id_physical(iIntern)) &"'" sql = sql& "LEFT(distributors_detail.cust_no, CHARINDEX('-', distributors_detail.cust_no) - 1) IN (" The line in the middle does not fit in. AND can be followed by OR and a string literal cannot be followed by a call to a system function. Mind you, reading SQL code which is so entwined with client code is difficult. And difficult to maintain. In any case, it does not seem that you have posted the actual query you have problem with. Or at least, I would expect a completely different error than a timeout error for a query that does not compile. So that leaves me a bit in the dark. -- Erland Sommarskog, SQL Server MVP, esq... (AT) sommarskog (DOT) se Books Online for SQL Server 2005 athttp://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books... Books Online for SQL Server 2000 athttp://www.microsoft.com/sql/prodinfo/previousversions/books.mspx |
#6
| |||
| |||
|
|
Sorry for the confusion in the last posting, I accidentally included a line that is commented out. As I said, I kind of got tossed into this one, and I'm trying to wade through and learn how everything works here. |
|
I have a development version of this table, and things work fine in there, with the same statement, so it leads me to believe there is some inconsistency in the data, as the number of records is not huge (~1000, ~300 international records) and there appears to be no blocking going on. |
#7
| |||
| |||
|
|
(RodStron... (AT) gmail (DOT) com) writes: Sorry for the confusion in the last posting, I accidentally included a line that is commented out. As I said, I kind of got tossed into this one, and I'm trying to wade through and learn how everything works here. OK. I had a vain hope that something more substantial was hidden for me. I have a development version of this table, and things work fine in there, with the same statement, so it leads me to believe there is some inconsistency in the data, as the number of records is not huge (~1000, ~300 international records) and there appears to be no blocking going on. I will have to admit that I'm out of ideas. The only thing I can think of is that there is some corruption. You could run DBCC CHECKTABLE on the table, or DBCC CHECKDB on the entire database. I would not really expect anything to come out of this, but at least we could tick it off the list. -- Erland Sommarskog,SQLServer MVP, esq... (AT) sommarskog (DOT) se Books Online forSQLServer 2005 athttp://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books... Books Online forSQLServer 2000 athttp://www.microsoft.com/sql/prodinfo/previousversions/books.mspx |
![]() |
| Thread Tools | |
| Display Modes | |
| |