Solved

VB.net SQL Client slow

Posted on 2014-11-08
10
236 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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 45

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
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…

762 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

22 Experts available now in Live!

Get 1:1 Help Now