Slow performance when editing cells during a search with highlighting enabled

Steps to reproduce:

  • Use a large dataset in an SfDataGrid (100s of rows) with cell values that are changing constantly (for example, live price data)
  • Do a search with highlighting and filtering enabled, ensuring the result of the search is also a large dataset.
  • Edit a numeric cell within the results.
  • The input is sometimes very slow. I am guessing because it is searching for and re-rendering all the highlighted text whenever the row's data is changed.

I am sure this is to do with the search highlighting as when I disable it I don't get performance issues when working with the search results. Is there a way to improve the performance of the search highlighting when the search results is quite large and the cell values are constantly changing?

Thanks,
Zia

9 Replies 1 reply marked as answer

SG Santhosh Govindasamy Syncfusion Team August 28, 2024 01:59 PM UTC

Hi Zia,

Thank you for reaching out and providing detailed information.

We tried to replicate the performance issue on our end by creating a sample where data is continuously updated, with search highlighting and filtering enabled. However, we were unable to observe any performance delays. The filtered records were correctly updated and highlighted based on the input search text as expected.

we noticed two additional behaviors when applying a search in this application. Could you please confirm if these align with what you were experiencing?

  1. Highlighting in Live Data Update Column: When searching for text, the highlighted records in the live data update column do not update in the UI or fail to reflect the changes. However, the remaining filtered records in the live data update column update correctly.
  2. Editing Values in Live Data Update Column: We noticed that when editing a value in the live data update column, the edited value sometimes gets overridden, particularly when live data continues to update while the edit is being made.

For your reference, I have attached a sample and a video demonstrating these behaviors. Could you please review them and confirm if they match the issue you are facing? Additionally, if you have any specific steps or scenarios where you consistently experience performance delays, please share those with us. This will help us further investigate the issue.

Thanks for your cooperation, and we look forward to your response.

Regards,
Santhosh.G


Attachment: Sample_DataGrid_11a95190.zip


ZI Zia September 3, 2024 09:37 AM UTC

Hi,

I think it is important to note that I have LiveDataUpdateMode set to AllowDataShaping which changes the behaviour of the search results. In the sample application you provided, setting the datagrid in this way seems to produce the problems I am experiencing.

Rows will appear and disappear in realtime during the search. Highlighted text will also change in realtime according to the search. It is also very difficult to edit anything during a search in this mode, sometimes it even crashes the sample application.

Perhaps there is a way to disable AllowDataShaping only during the search?

Thank you,

Zia



ZI Zia September 3, 2024 10:58 AM UTC

I think I have resolved this by manually changing the LiveDataUpdateMode to Default during the search and then setting it back to AllowDataShaping when the search is cleared.​


Marked as answer

SG Santhosh Govindasamy Syncfusion Team September 4, 2024 04:38 AM UTC

Hi Zia,

We are glad to know that the reported problem has been resolved at your end. Please let us know if you have any further queries on this. We are happy to help.


Regards,
Santhosh.G



ZI Zia November 22, 2024 01:59 PM UTC

Unfortunately I am still having this problem. The performance issue is still solved by disabling the search highlighting, but I do need the highlighting. 

I have 5 tables on screen, each with 26 columns and about 200 rows each of constantly changing live data.

One thing I've noticed is RowGenerator.RowsArranged is being triggered very often while I'm in a search which seems to be triggering a re-evaluation of all the cells highlighting. I'm wondering if this is maybe what is making it slow during a search.

I only need the highlighting to be shown on the initial search, I do not need the highlighting updated as the data values change.

I will continue to investigate and see if I can find anything else.



MA Manikanda Akash Munisamy Syncfusion Team November 25, 2024 11:24 AM UTC

Hi Zia,

Based on the details provided, we have tested a scenario with five DataGrids, each containing 26 columns and 200 rows. We performed a search operation with the "Highlight Search Text" feature and did not observe any performance issues. For your reference, we have attached the tested sample.

If your issue differs from this scenario, kindly provide additional details. Additionally, if you encounter performance delays under specific steps or conditions, please share those with us. This information will assist us in further investigating the issue.

Thank you for your cooperation. We look forward to your response.

Regards,
Manikanda Akash

Attachment: SfDataGrid_Demo_c534065a.zip


ZI Zia November 25, 2024 01:16 PM UTC

I've come up with a bit of a hacky solution. Its not ideal as it uses a timer, but it seems to work in my case. I've created a custom search helper which allows me to suspend updates to the search results. Then after executing a search I manually suspend the updates after a short wait time. Performance has improved significantly.

public class CustomSearchHelper : SearchHelper
{
    public CustomSearchHelper(SfDataGrid sfDataGrid) : base(sfDataGrid)
    {
    }

    public bool SuspendSearchUpdates { get; set; }

    protected override void SearchRow(DataRowBase row)
    {
        if (SuspendSearchUpdates) return;
        base.SearchRow(row);
    }
}

...

public void ApplySearch(string text)
{
    var searchHelper = (CustomSearchHelper)MyDataGrid.SearchHelper;

    if (string.IsNullOrEmpty(text))
    {
        searchHelper.SuspendSearchUpdates = false;

        MyDataGrid.SearchHelper.ClearSearch();
        MyDataGrid.LiveDataUpdateMode = LiveDataUpdateMode.AllowDataShaping;

        return;
    }

    MyDataGrid.LiveDataUpdateMode = LiveDataUpdateMode.Default;

    searchHelper.SuspendSearchUpdates = false;

    MyDataGrid.SearchHelper.Search(text);

    // Block further updates to the search results
    Task.Delay(500).ContinueWith(t =>
    {
        searchHelper.SuspendSearchUpdates = true;
    });
}


ZI Zia November 25, 2024 01:31 PM UTC

I managed to reproduce the problem on the example you provided. Doesn't always happen though.

1) Search for '.' . This should give a large number of search results.

2) In the last datagrid, start typing with one of the Symbol cells selected.


I observed that the cell was not showing what I was typing. Pressing enter did not update the cell with what I typed either. This is similar to the behaviour I was experiencing in my own application.

image.jpg



MA Manikanda Akash Munisamy Syncfusion Team November 26, 2024 12:49 PM UTC

Hi Zia,

Thank you for sharing the details to reproduce the performance issue you are experiencing.

Upon reviewing the information, we identified that the frequent triggering of RowGenerator.RowsArranged is caused by the AllowFiltering being enabled for the SearchHelper. This results in rows in view being updated upon every search. Given that the data updates live and large volumes of data match the search criteria, the frequent filtering and updates contribute to the observed performance issues.

We recommend continuing to use the workaround you shared as it effectively addresses the performance challenge.

Should you require further assistance or have additional observations, please let us know. We are here to help.

Regards,
Manikanda Akash

Loader.
Up arrow icon