Solved

Slow Vb.net program.

Posted on 2011-03-25
6
302 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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Article by: Nadia
Suppose you use Uber application as a rider and you request a ride to go from one place to another. Your driver just arrived at the parking lot of your place. The only thing you know about the ride is the license plate number. How do you find your U…
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 this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

707 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

12 Experts available now in Live!

Get 1:1 Help Now