Solved

VB.net SQL Client slow

Posted on 2014-11-08
10
239 Views
Last Modified: 2014-11-14
Hi

I am using VB.net SQL Client to pull data on my local connection from a view that has 6 million records.
In the process I count the number of items in for instance a column called "Plant" that can contain only one of two
values "P01" and "P02". If I count the number of records that contain "P02" it times out. I tested it in SQL Server Management Studio and it took three minutes.
Is the technology the problem or is this something that might be caused by the speed at which my computer is running?
0
Comment
Question by:murbro
  • 3
  • 3
  • 2
  • +2
10 Comments
 
LVL 33

Expert Comment

by:Mike Eghtebas
ID: 40430880
If it returns total of P01" and "P02", and it is not grouped by, say "Plant", using a function call, you may want, to have total of "P01"s and then say total op "P02"s = Number or records in the tabale - "P01"s

But I don't it is this simple and there must be some category of some sort to group by. Just a thought.
0
 
LVL 62

Expert Comment

by:Fernando Soto
ID: 40431273
This sound like a need to implement a index on the column "Plant" which should drastically increase the response time. I am not an SQL database Guru so I can't direct you in how to go about this implementing the index.

In answer to to your question, "Is the technology the problem or is this something that might be caused by the speed at which my computer is running?", well the technology is not the problem. The problem is that it sounds like the database table/view is poorly designed for what you need to do.
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 40431318
how do you count them? it should look like this:

select Plant, count(*) from YourTableName

Open in new window


I am not sure that creating an index would help in this case as you only have 2 values (not enough discriminating)
0
 
LVL 62

Expert Comment

by:Fernando Soto
ID: 40431330
Hi Eric;

Seeming that an index will segregate the values stored in the column, so all "P01" will be together and all "P02" will be together, and you want to query for only "P01" and lets say that "P01" is 1/4 of the 6 million records then it would only take 1/4 of the time to return the known "P01" records?
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 40431428
not in the case of a count where all the rows needs to be scanned
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 62

Expert Comment

by:Fernando Soto
ID: 40431433
Hi Eric;

In the question it states this, "If I count the number of records that contain "P02" it times out.", so are you saying that SQL server would not optimize the query plan to take into account the index of that column seeming you would not be counting all entries?
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 40431435
would need to check the execution plan.
0
 
LVL 33

Expert Comment

by:Mike Eghtebas
ID: 40431474
murbro,

1. What the query looks like, are there other fields involved?

2. What is your connection string?

3. Paste the try catch with the rest of the code here. If no try catch, still paste the code for us to see.

Mike
0
 
LVL 46

Accepted Solution

by:
Vitor Montalvão earned 500 total points
ID: 40432375
If I count the number of records that contain "P02" it times out. I tested it in SQL Server Management Studio and it took three minutes.
That's because in SSMS you don't have a timeout period set but you do in VS. You need to change the timeout period in the connection in VS (by default is 30 seconds).
Also as recommended here by Fernando Soto, an index on the column may help increase the performance of your query.
0
 

Author Closing Comment

by:murbro
ID: 40442676
thanks
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Viewers will learn how the fundamental information of how to create a table.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now