Vb.Net - Design/Speed Recommendation

Good Day Experts!

I am in need of some design assistance with my little project.  This is kind of like a the traditional Hdr/Dtl SQL table setup but a slightly different.  Instead of let's say an invoice number Hdr record with part number Dtl records...I have Hdr table records that contain those part Numbers.  However, I still do need to get to the Dtl table to get info for each part number.

I am building a CSV file.  To process and build the CSV file for one 650 record invoice it is taking about 12minutes.  I suspect it may be the call to the db each time through the loop to get the detail information.  The Dtl table contains potentially multiple records for a part number.  So, I was trying to not do a join in my initial loop query just to keep the processing "cleaner" and "easier" but I am questioning that.

Would you think it would be better loop through the Hdr record and grab all the Dtl table records putting them in a DataTable instead of making a call to the Database 650 times?

Please ask more questions as I probably did not explain completey.

Who is Participating?
käµfm³d 👽Connect With a Mentor Commented:
Do you have proper indexes on your tables? And have you built your queries to take advantage of those indexes?
The best and most powerfull  solution in this case: Use LinQ

This will Eliminate 99% of the DB queries. and you app will be far faster. you won't need 650 DB calls anymore!

Take a look here:


I suggest to go through all 100 examples. It will pay for your every second of time reading it!

Simple+ powerful
Jimbo99999Author Commented:
I will look at the indexes.  The tables have been around for years.  Perhaps I am not hitting them right.

Jimbo99999Author Commented:
After looking, I found there are no keys on the table when there should be.  Sounds like I need to go see the Administrator.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.