Solved

Slow Vb.net program.

Posted on 2011-03-25
6
309 Views
Last Modified: 2012-05-11
Hi All

I made a billing system that run thought about 2000 records aday, it used to be really fast as in about 40 in one second but i change a few minor thing and now it's mega slow as in one every 2.5 seconds.

Anyidea how to find out which part of the code is slowing it down.... I know could do it be "trial and error" i.e. testing one bit of the code at a time.

All I add was a case statement with 6 cases... this should slow it down that much should it?

Cheers

Matt
0
Comment
Question by:Matb396
6 Comments
 

Expert Comment

by:Casirus
ID: 35214035
well from my own experience if it is pulling the info from a database and then running it through Case statements it can slow down an app greatly i ended up having to go deeper into multi-threading to fix my problem

so what you could do is
1. Multi-Thread the Case selection code
2. Remove the Case Code
3. Find a work around for the case select by using another form of statement like an IF statement yes it may be a low end solution but it can work thought there is a chance it would still run slow

i hope my input helps in some way

D.L.H.
0
 
LVL 13

Expert Comment

by:gamarrojgq
ID: 35215288
Hi,

First you will have to remove the Case and try it, so you can be sure that really is the Case that it is slowing down the application.

If after remove it, your application run faster again, you have to consider make the CASE inside your SQL Select Statement depending on what DB are you using.

But, after remot it, the application is still slow, you will have to check your entire process or  DB Connection problems.
0
 

Author Comment

by:Matb396
ID: 35215320
The case statement is on some CSV data, so can't be done in the sql.

Is 6 IF statement fast then one case with 6 cases?

Matt
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 28

Accepted Solution

by:
Ryan McCauley earned 500 total points
ID: 35215781
What happens if you put the code back the way it was before you "changed some things" - is it quick again? If it is, then it's the code you added - if it's not, maybe the database has grown or changed and needs an index to speed things up again.

How are you processing your data - are you fetching the rows from the database one by one, or are you fetching all the rows at once from the database and then operating on them one at a time in your application? The second way is most likely faster - it's fewer calls to the database, and most databases are best operating on sets of rows and returning them all, instead of doing tons of one-off lookups (they will return 100 rows much more quickly than they will return 100 different rows one at a time).

If all you've changed is a few things and now it's slow, look at what you've changed. Have you added any loops that are unnecessary (or contain unnecessary steps)? If you step through your code, are there some steps that seem to take a long time? Are you making any calls to other systems that take a second or two to complete, and are you making those calls for every row?
0
 
LVL 13

Expert Comment

by:gamarrojgq
ID: 35215878
In theory the select case should be faster, since it's a lookup table.
0
 

Author Closing Comment

by:Matb396
ID: 35215986
yes there was a problem with the indexing in the database.

After re-indexing it i run much fast!

cheers

matt
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
The greatest common divisor (gcd) of two positive integers is their largest common divisor. Let's consider two numbers 12 and 20. The divisors of 12 are 1, 2, 3, 4, 6, 12 The divisors of 20 are 1, 2, 4, 5, 10 20 The highest number among the c…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

825 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