Solved

VB.net SQL Client slow

Posted on 2014-11-08
10
249 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +2
10 Comments
 
LVL 34

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 63

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 70

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
Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

 
LVL 63

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 70

Expert Comment

by:Éric Moreau
ID: 40431428
not in the case of a count where all the rows needs to be scanned
0
 
LVL 63

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 70

Expert Comment

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

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 50

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

752 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