Performance issues with databinding

Posts   
 
    
scotru
User
Posts: 104
Joined: 16-Feb-2006
# Posted on: 06-Jan-2008 07:35:17   

Greetings,

I have an application recently ported to VS 2005, using LLBLGen 1.0.2005.1 Final. I am suffering from severe performance issues when loading certain fairly complex multitabbed data forms.

I have a table with about 7000 rows, approximately 50 fields, each bound to a control on a multi-tabbed form with a listview control that shows all records (just a couple of fields) and allows you to select the record you wish to see detail for. (Additionally, some taps show rows from related tables)

Originally, I was trying to load the entire table into a collection, but found that performance was unacceptable.

So I switched to using a TypedList to display my summary list, and then tried to fetch a full individual entity only when it was selected from the list.

My problem is that the databinding will only update when I rebind the data controls after each new item is selected. Remove and add the databindings is extremely performance intensive. I've tried only binding controls on the active tab, but performance is still unacceptable.

It seems like I'm dealing with a trivially small amount of data, so I know I'm not doing something right here. Does anyone have suggestions for me? Will upgrading to the newer version of LLBLGenPro help? Are there fundamental architectural changes I need to consider?

Additional info: I'm using Self-Servicing model for VS 2005 with MySql backend CoreLab 3.20.9.0

Thanks!

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 06-Jan-2008 11:04:20   

With performance issues it's always essential to know where exactly the performance bottleneck is before anything can be done about it. So as you state that you bind 7000 rows to a control, I am pretty sure that isn't very fast. Could you test if just binding the 7000 rows to the listbox is the bottleneck?

Frans Bouma | Lead developer LLBLGen Pro
scotru
User
Posts: 104
Joined: 16-Feb-2006
# Posted on: 07-Jan-2008 12:46:34   

Hey Otis,

Thanks for your quick response. Well, actually, the binding 7000 rows to my control isn't as bad as you might think (it's not particularly quick, but it's not too slow either). The real problem seems to be creating and destroying the databindings each time the active (selected) entity changes.

I seem to have to do this for the controls to recognize that the data has changed.

Here's an example of the code that's killing me:


   private void bindStudentMedical()
        {
            //
            // Medical Tab
            //
            txtMedicalNotes.DataBindings.Clear();
            txtMedicalNotes.DataBindings.Add("Text", theStudent, "MedicalInfo.MedicalNotes");
            txtMedicalArrangements.DataBindings.Clear();
            txtMedicalArrangements.DataBindings.Add("Text", theStudent, "MedicalInfo.Arrangements");
            txtPhysician.DataBindings.Clear();
            txtPhysician.DataBindings.Add("Text", theStudent, "MedicalInfo.Physician");
            txtPhysicianPhone.DataBindings.Clear();
            txtPhysicianPhone.DataBindings.Add("Text", theStudent, "MedicalInfo.PhysicianPhone");
            txtInsurance.DataBindings.Clear();
            txtInsurance.DataBindings.Add("Text", theStudent, "MedicalInfo.InsuranceCompany");
            txtInsurancePolicyNum.DataBindings.Clear();
            txtInsurancePolicyNum.DataBindings.Add("Text", theStudent, "MedicalInfo.InsurancePolicy");
            chkDisease.DataBindings.Clear();
            chkDisease.DataBindings.Add("Checked", theStudent, "MedicalInfo.MedicalDisease");
            chkAllergies.DataBindings.Clear();
            chkAllergies.DataBindings.Add("Checked", theStudent, "MedicalInfo.MedicalAllergies");
            chkMedication.DataBindings.Clear();
            chkMedication.DataBindings.Add("Checked", theStudent, "MedicalInfo.MedicalMedicationAllergies");
            chkOngoing.DataBindings.Clear();
            chkOngoing.DataBindings.Add("Checked", theStudent, "MedicalInfo.MedicalOngoing");
            txtEmergencyName.DataBindings.Clear();
            txtEmergencyName.DataBindings.Add("Text", theStudent, "MedicalInfo.EmergencyContact");
            txtEmergencyAddress.DataBindings.Clear();
            txtEmergencyAddress.DataBindings.Add("Text", theStudent, "MedicalInfo.EmergencyAddress1");
            txtEmergencyCity.DataBindings.Clear();
            txtEmergencyCity.DataBindings.Add("Text", theStudent, "MedicalInfo.EmergencyCity");
            txtEmergencyState.DataBindings.Clear();
            txtEmergencyState.DataBindings.Add("Text", theStudent, "MedicalInfo.EmergencyState");
            txtEmergencyPostal.DataBindings.Clear();
            txtEmergencyPostal.DataBindings.Add("Text", theStudent, "MedicalInfo.EmergencyPostal");
            txtEmergencyHomePhone.DataBindings.Clear();
            txtEmergencyHomePhone.DataBindings.Add("Text", theStudent, "MedicalInfo.EmergencyHomePhone");
            txtEmergencyWorkPhone.DataBindings.Clear();
            txtEmergencyWorkPhone.DataBindings.Add("Text", theStudent, "MedicalInfo.EmergencyWorkPhone");
            txtEmergencyPagerPhone.DataBindings.Clear();
            txtEmergencyPagerPhone.DataBindings.Add("Text", theStudent, "MedicalInfo.EmergencyCellPhone");
            txtEmergencyCellPhone.DataBindings.Clear();
            txtEmergencyCellPhone.DataBindings.Add("Text", theStudent, "MedicalInfo.EmergencyPagerPhone");
            txtEmergencyOtherPhone.DataBindings.Clear();
            txtEmergencyOtherPhone.DataBindings.Add("Text", theStudent, "MedicalInfo.EmergencyOtherPhone");
        }

Here's what calls it (bindStudent calls a function that depends on the active tab rather than binding the controls for all the tabs--this helped):


        private void studentControl1_SelectedValueChanged(object sender, EventArgs e)
        {
            if(studentControl1.SelectedIndex != -1)
            {

                // this student/tab is already bound, so skip rebinding
                if (theStudent!=null)
                    if (((int)studentControl1.SelectedValue == boundStudentId) && (boundTab==tabStudents.SelectedIndex))
                        return;
                theStudent = new StudentsEntity((int)studentControl1.SelectedValue);
                bindStudent();
            }
        }


I tried to use something like:


                theStudent.FetchUsingUCStudentId((int)studentControl1.SelectedValue);

rather than creating a new entity that I have to rebind to. But none of the controls updated to reflect the new data.

I've attached the complete code file for reference.

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 08-Jan-2008 12:20:11   

I tried to use something like:

            theStudent.FetchUsingUCStudentId((int)studentControl1.SelectedValue);

rather than creating a new entity that I have to rebind to. But none of the controls updated to reflect the new data.

I've attached the complete code file for reference.

I think the above should work if you use a BindingSource, that act as the middle man between the controls and the entity.

scotru
User
Posts: 104
Joined: 16-Feb-2006
# Posted on: 09-Jan-2008 09:37:02   

Thanks very much, I will look into this. I am porting this application from .NET 1.1 (which was my last experience in the .NET platform) and I don't think this class existed at that time.

scotru
User
Posts: 104
Joined: 16-Feb-2006
# Posted on: 15-Jan-2008 22:31:19   

I tried using a binding source as a middle man, the controls still do not update. Help!

Thanks!

scotru
User
Posts: 104
Joined: 16-Feb-2006
# Posted on: 15-Jan-2008 22:42:42   

After binding to the bindingsource control, a call to:

bindingsource1.CurrencyManager.Refresh()

after changing the data source seems to resolve the issue.

Is this normally required?

Thanks!

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 16-Jan-2008 08:58:11   

Yes, that's valid and normal.

tangent
User
Posts: 41
Joined: 30-Apr-2006
# Posted on: 19-Jan-2008 10:34:12   

Here is some other links you may want to check out regarding using bindingsource with llblgen entities. There are a few 'issues' when using bindingsource with objects which inherit from IEditableObject, such as LLBL entities.

http://technet.microsoft.com/en-us/library/ms404299(VS.80).aspx http://msdn2.microsoft.com/en-us/library/ms404320.aspx

scotru
User
Posts: 104
Joined: 16-Feb-2006
# Posted on: 27-Jan-2008 00:13:54   

Thanks Tangent--very helpful!