If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Visual Basic > ADO Timeout

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-09-09, 13:03
helen_m helen_m is offline
Registered User
 
Join Date: Sep 2009
Posts: 7
ADO Timeout

I have a VB6 application that is occasionally timing out on a simple query:

DELETE FROM items3 WHERE LastActionID = 101000

The value of LastActionID can vary. The items3 table contains roughly 4 million rows, the number of items to be deleted is around 1000, the table is indexed on LastActionID.

The command is issued through an ADO Command object - the Timeout is set to 0, which means that the application hangs at that point. Setting the Timeout to any other value means the application receives a timeout error. Running the same command through SQL Server Management Studio executes in less than .1 of a second. The command is one of a sequence - the other commands above it all execute fine.

I've tried setting .Properties("Access Order") = 0 with no effect (as suggested for a similar timeout error on a stored procedure). "SELECT @@LOCK_TIMEOUT" returns -1.

I'm now struggling - as I can't think of a much simpler query to do. More baffling is that sometimes it just works.

Help!
Reply With Quote
  #2 (permalink)  
Old 09-09-09, 13:30
Ax238 Ax238 is offline
Registered User
 
Join Date: May 2009
Posts: 257
Hi and welcome to the forums,

Make sure the CommandTimeout property of the connection object is also set to 0.

Regards,

Ax
Reply With Quote
  #3 (permalink)  
Old 09-09-09, 14:58
helen_m helen_m is offline
Registered User
 
Join Date: Sep 2009
Posts: 7
Unfortunately that's already set...
Reply With Quote
  #4 (permalink)  
Old 09-10-09, 09:21
Ax238 Ax238 is offline
Registered User
 
Join Date: May 2009
Posts: 257
What error message are you getting exactly?
Reply With Quote
  #5 (permalink)  
Old 09-10-09, 12:04
helen_m helen_m is offline
Registered User
 
Join Date: Sep 2009
Posts: 7
Well, if I leave the code exactly as-is, I don't get an error message because the application just hangs waiting for a response from the database.

If I step through the code, ignoring the line which sets the command's CommandTimeout property to 0 (ie. leaving it at the default), I get the ADO timeout error message (code -214217871, description Timeout expired).

It seems as though SQL Server is getting in a mess with its execution plan, but I don't know how to force SQL Server to evaluate this simple query properly, using the pre-defined index.
Reply With Quote
  #6 (permalink)  
Old 09-15-09, 12:22
Ax238 Ax238 is offline
Registered User
 
Join Date: May 2009
Posts: 257
Sorry for the late response. Instead of using a command object, why not try using the Connection.Execute method?
Code:
objCon.Execute "DELETE FROM items3 WHERE LastActionID = 101000"
It may or may not help out, you may be right that something is up with the SQL Server.

Ax
Reply With Quote
  #7 (permalink)  
Old 09-15-09, 14:04
helen_m helen_m is offline
Registered User
 
Join Date: Sep 2009
Posts: 7
Hi Ax, thanks for the suggestion.

Unfortunately it still times out (or hangs...) using the connection.execute rather than the command.execute.

Does anyone know why SQL Server would behave one way with ADO but another way using Management Studio? Is this something I should go to Microsoft with?
Reply With Quote
  #8 (permalink)  
Old 09-16-09, 10:04
Teddy Teddy is offline
Purveyor of Discontent
 
Join Date: Mar 2003
Location: The Bottom of The Barrel
Posts: 6,075
Honestly I think you're attacking the wrong end of the pipe. Even with millions of records there is probably a way to optimize performance on the server side of things. You can provide index hints as you alluded to earlier using the WITH() table hint syntax. You should be able to find some info on this in BOL by searching for "table hints".
__________________
oh yeah... documentation... I have heard of that.

*** What Do You Want In The MS Access Forum? ***
Reply With Quote
  #9 (permalink)  
Old 09-21-09, 14:41
helen_m helen_m is offline
Registered User
 
Join Date: Sep 2009
Posts: 7
ooo - I thought Teddy had something there - the WITH statement appeared to be exactly what I needed. Then our database server broke...

Anyhow, it's back up and running again. Submitting DELETE FROM items3 WITH (INDEX(idx_items3_last_action_id)) WHERE last_action_id = 101000 gave an error indicating that a FROM clause was needed! A quick Google indicated that Microsoft weren't treating the FROM statement as a FROM statement!

The workaround which was accepted by SQL Server was DELETE FROM items3 FROM items3 WITH (INDEX(idx_items3_last_action_id)) WHERE last_action_id = 101000 - but it still hangs...
Reply With Quote
  #10 (permalink)  
Old 09-21-09, 18:05
loquin loquin is offline
Super Moderator
 
Join Date: Jun 2004
Location: Arizona, USA
Posts: 1,797
Are you using ODBC or OleDB in your connection?
__________________
Lou
使大吃一惊
"Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
"I have my standards. They may be low, but I have them!" - Bette Middler
"It's a book about a Spanish guy named Manual. You should read it." - Dilbert

Reply With Quote
  #11 (permalink)  
Old 09-22-09, 03:07
helen_m helen_m is offline
Registered User
 
Join Date: Sep 2009
Posts: 7
SQLOLEDB. The informal response from buddy who works at Microsoft is "upgrade" and "rewrite in .net". Thanks...
Reply With Quote
  #12 (permalink)  
Old 09-22-09, 14:29
helen_m helen_m is offline
Registered User
 
Join Date: Sep 2009
Posts: 7
A further update - our server was rebuilt as a RAID 5 array, which is the same hardware configuration as the customer's server. Now, the delete (run from Management Studio) takes flipping years. Three-and-a-half hours and counting for deleting 790 records out of 4,000,000, on the indexed column. It would be quicker to do it manually in Excel!

There are sites that talk about doing deletes in chunks, but they all use stored procedures, that we (with our policy of supporting Oracle as well) cannot use.

Why on earth is SQL Server taking so, so long to delete a handful of records? Back to the drawing board...
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On