Solved

VB.net SQL Client slow

Posted on 2014-11-08
10
245 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 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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
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 48

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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

839 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