Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Program getting very slow 1

Status
Not open for further replies.

MJV57

Programmer
Apr 18, 2009
87
CA
I have a form that is attached to a large data base via a dataset but as the database gets larger this form gets slower and slower. I use this form to edit records that have already been created. When I open the form it pulls up all the records and you use the arrow buttons on the binding navigator bar to get around. Is there a better way to do this that will spead up my code. It is chewing up an enourmous amount of ram.
 
if you are not paging your records then you're pulling all the data from the table into memory to display. To solve this problem you should implement paging.

not sure about win forms, but webforms does a terrible job at implementing an efficient paging solution so devs must implement there own solution.

some data access frameworks take care of this for you.
LLBL
NHibernate
Active Record

not sure about MS Enterprise Library Data Access.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
This is the code to load my forms. How would I implement paging to this?

private void Form1_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'estimatorDataSet.QuoteCalcHeader1' table. You can move, or remove it, as needed.
this.quoteCalcHeader1TableAdapter.Fill(this.estimatorDataSet.QuoteCalcHeader1);
// TODO: This line of code loads data into the 'estimatorDataSet.QuoteCalcBody1' table. You can move, or remove it, as needed.
this.quoteCalcBody1TableAdapter.Fill(this.estimatorDataSet.QuoteCalcBody1); }
 
this doesn't tell me anything.

I haven't worked with DataSet/Adapters in years, but I'm guessing that these 2 memebers are loading all "quotes" that have been calculated into memory. It doesn't look like you are filtering the data in any way.

if that's the case, how many quotes are there on average? is this data volatile (does is change frequently)? How is this data used in the current context?


Jason Meckley
Programmer
Specialty Bakers, Inc.
 
I guess filtering is the best option.
 
filtering will help, but the problem still comes down to the amount of data selected.

example :
you want to see all orders within a date range. this could be 10 rows, 10,000 rows or 10,000,000 rows. 10 rows in manageable, 10,000 is not. You still want to page through the 10,000 records for usability and preformance.

most db paging solutions look like this
Code:
create [temp table] (
   [columns in select statement], 
   row_number identity(0,0)
);

insert into [temp table] ([columns])
select   [columns] 
from     [tables] 
where    [criteria]
order by [sort];

select [all columns except row_number] 
from   [temp table] 
where  row_number >= @page_index 
 and   row_number <= @page_index + @page_size;

drop [temp table];

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top