Hi Team Syncfusion,
Please see this repository:
https://github.com/Mike-E-angelo/Stash/tree/master/Syncfusion.Grid.State
After running it and loading Index.razor, you will see this line get hit twice:
https://github.com/Mike-E-angelo/Stash/blob/master/Syncfusion.Grid.State/Pages/Index.razor#L48
Expected: This line should only be called once.
Commenting out these lines makes it work as expected:
https://github.com/Mike-E-angelo/Stash/blob/master/Syncfusion.Grid.State/Pages/Index.razor#L80-L87
So it would seem that `SetPersistDataAsync` invokes two calls to the DataAdaptor.Read method, when only one is expected.
Please let me know if there is any further information I can provide to further assist and diagnose this issue.
Hi Mike,
Greetings from Syncfusion support.
We have analyzed your query and check the provided sample. We would like to inform that SetPersistanceDataAsync method is used to load the previously saved state of grid. So that, read method get hit twice in the provided sample. This is the default behaviour of this method. Please refer the attached reference link.
Kindly get back to us if you have any further queries.
Regards,
Sarveswaran PK
Thank you for the reply @Sarveswaran. I understand that i is currently default behavior, or at least the behavior as currently experienced. However, this seems like it is a bug as you would be able to note on your side that the data has already been retrieved and does not need to be retrieved a second time on page load.
Because of this issue, two calls are being made to my database whenever I load your control on my pages, of which there are about 100 of them throughout my application. This seems a bit wasteful and unnecessary.
I appreciate any consideration towards addressing this issue on your side.
Hi Mike,
Greetings from Syncfusion support.
Thanks for taking time to informing us and we’ll check with concern dev team and update you the further details.
Until then we appreciate your response.
Kindly get back to us if you have any further queries.
Regards,
Sarveswaran PK
Hi @Sarveswaran I wanted to check in with this to see when this can be addressed. I have disabled the state on my grid controls but customers are noticing this and are making comments. So now I am in between two difficult propositions of having no state or state with two calls to the database with each call.
Thank you for any update you can provide.
Hello any update would p
Hi Mike,
Sorry for the delay,
Based on your update, we'd like to inform you that in order to persist the filter settings, sorting and group-by methods, it is necessary to recall the Read method again. This is the default behavior. But from your sample, you only update the column properties, so you need not to data process again. Please let us know, If you’re not using filtering, sorting, grouping in your project, and you need only update the column. We’ll consider this as bug and implement in upcoming patch release.
Regards,
Sarvesh
Hi @Sarveswaran,
Thank you for your update. I am indeed using sorting/filter as that is how a grid is typically used. Based on my investigation, the query to the database is exactly the same twice. As such, it would seem that the first call would be utilized/stored/cached on the client so that two calls to the database are not necessary.
Please do let me know if I have something misunderstood.
Hi @Saeveswaran I would like to get this attended to sooner rather than later as it is a performance issue with my application. Thank you for any update/effort you can provide.
Hi Sarveswaran I wanted to check in with this issue as I have not heard back since November 8. Thank you for any update you can provide.
Hi Mike,
Sorry for the delay and inconvenience caused.
Hi Mike,
Sorry for the delay.
It is necessary to recall the Read method once more in order to maintain the filter settings, sorting, and grouping methods, as we previously explained. If some users use an external button to call the SetPersistDataAsync method, the Read method must be called once to read the DataProcess. In your scenario, rendering SetPersistDataAsync method within OnAfterRenderAsync cycle leads to calls the read method twice. This is the default behavior in nature.
Regards,
Sarvesh
Thank you for the update @Sarvesh. In this case this is not a button being pressed, but basic grid initialization. Is there no way to defer the Read call during this scenario so that only one call is made to the database?
In some cases, I have more than one grid on a page so this is a compounding problem for my system.
Ideally, it would be valuable to have some way to signal to the grid that "hey I am going to call `SetPersistDataAsync` so please hold off on calling read during initialization until this is done."
That way this results in only one call during initialization.
Thank you for any consideration you can provide towards this.
Hi Sarvesh I wanted to check in with this as I have not heard back and this is a priority for my application. The goal here is to only have ReadData called once during initialization. Thank you for any guidance/consideration you can provide.
Hi Sarvesh thank you for any update you can provide.
Hi Mike,
Sorry for the late response from our end.
As we explained earlier, if we persist the filter settings, sorting and
group-by methods, it is necessary to recall the Read method again. If some users use an
external button to call the SetPersistDataAsync method, the Read method
must be called once to read the DataProcess. This is the purpose of us to
call the ReadMethod while using SetPersistDataAsync method. In your scenario,
rendering SetPersistDataAsync method within OnAfterRenderAsync cycle leads to
calls the read method twice. But from your sample, you only update the
column properties, so you need not to data process again. If yes, we’ll
consider this as bug and include in any of our upcoming patch release.
Regards,
Sarvesh
Thank you for your reply @Sarvesh. Do pardon the confusion here but it's not just ReadData that is being called, but the Sql Server that is being called twice. This is occurring on every page that has an SfGrid control on it. In some cases, I have 3 grids so that is 6 calls to my Azure Sql Database which consumes DTU and ultimately costs me money. I hope that further explains my concern here.
In the sample I provided, you should see that SQL commands sent out to the SQL server are being generated and executed twice, and the expectation is that they only get generated and executed once.
Thank you for any further assistance/consideration you can provide toward improving this scenario.
Hi Mike,
Query: “it's not just ReadData that is being called, but the Sql Server that is being called twice.”
We suspect that the SQL server is called twice. Because inside the Read method we have fetched the data from the SQL server. So if we prevent the ReadAsync call then the call to the SQL will be prevented and kindly confirm us whether you are mentioning the same issue.
|
public override object Read(DataManagerRequest dm, string key = null) { Debug.WriteLine($"{nameof(CustomAdaptor)}.{nameof(Read)}"); IEnumerable<Order> DataSource = db.GetAllOrders();
|
Please get back to us if we misunderstood your query or if you have further queries.
Regards,
Monisha
Hi Monisha,
Pardon the false alarm here. I did try to unmark my previous answer as the solution, but there was no way to do so, so I deleted it.
I did look into working around this, but the problem is this:
As a result, this makes 2 calls to the database. Is there a way to avoid this?
Please let me know if that better explains the problem. Thank you for any further assistance you can provide.
Hi Monisha & Team, I wanted to check in on this issue. Please let me know if there is any further information I can provide to help diagnose and/or explain the issue.
Again, when manually loading data via `SetPersistDataAsync` another subsequent call is made after this that is not expected/desired, leading to two calls to the database rather than one.
Thank you for any consideration towards addressing this.
Hi Mike,
We have validated and considered your query as a bug and logged the defect report “Prevent SetPersistDataAsync method to call Read method twice” for the same. Thank you for taking the time to report this issue and helping us improve our product. At Syncfusion, we are committed to fixing all validated defects (subject to technological feasibility and Product Development Life Cycle) and will include the fix in any of our upcoming patch release.
You can now track the current status of your request, review the proposed resolution timeline, and contact us for any further inquiries through this link.
Disclaimer: “Inclusion of this solution in the weekly release may change due to other factors including but not limited to QA checks and works reprioritization”
Until then we appreciate your patience.
Regards,
Sarveswaran PK
Woohoo! Great, thank you so very much Sarveswaran and team! Happy Holidays to everyone out there 🎅⛄🎄
Huh, that would be great if you could find a solution!
Hi @Sarveswaran any update here please?
Hi Mike-E ,
We are glad to announce that our Essential Studio 2022 patch Release v20.4.0.48
is rolled out and is available for download under the following link and we
have included fix for the issue “Prevent SetPersistDataAsync method to call Read
method twice” in our patch release (20.4.0.48).
NuGet : https://www.nuget.org/packages/Syncfusion.Blazor.Grid
We thank you for your support and appreciate your patience in waiting for this release. Please get in touch with us if you would require any further assistance.
Regards,
Sarvesh
Whoohoo! Thank you very much Sarvesh and team! Your efforts are greatly appreciated.
Hi Mike,
We are glad that the provided solution helped to solve the issue. Please get back to us for further assistance.
We are marking this ticket as solved.
Regards,
Suganya Gopinath.
I can confirm here that using 2.4.0.48 within my provided solution only call the database once now. Thank you very very much out there Suganya, Sarvesh, and team. :)
Hi Again 😇
Unfortunately, there appears to be another issue here. If one request is ongoing (taking some time) this still gets called twice.
Please see the solution now, with this edit:
https://github.com/Mike-E-angelo/Stash/blob/master/Syncfusion.Grid.State/Pages/Index.razor#L44
Thank you for any further suggestions/consideration you can provide.
Hi Mike-E,
Sorry for the delay and inconvenience caused.
From your query, we would like to inform you that async functions render tasks
simultaneously. If we hold a specific task using the delay await keyword, it
will be held for 1000ms, and then the specific task starts rendering. This
could be the reason for the read method called twice.
Please let us know if you have any further queries or
concerns.
Regards,
Sarvesh
Thank you for your reply, Sarvesh. In my real-world case, I am not using `Task.Delay` of course. I am make a call to my database which takes some time. So much time, in fact, that it causes the control to call twice. I still get two calls to the database as a result.
Is there some way to address this?
Hi Mike-E,
Sorry for the delay.
We would like to inform you that the Read method is sufficient for synchronous
operations and the ReadAsync method is used for asynchronous operations. We
suspect that you are using the ReadAsync method for the
synchronous operation, which may cause an issue based on your sample. So,
please switch from synchronous to asynchronous operation. If still you’re
facing an issue, please share the runnable sample with us so that we can
validate it further at our end.
Regards,
Sarvesh
Hi Sarvesh, thank you for your continued assistance, and no worries at all about the delay. :)
Please note that I provided an example of this here:
Please do let me know if I have misunderstood something and/or if there is any further information I can provide to help further diagnose this issue for you.
Hi Sarvesh have you been able to look at the provided solution? I still experience the same double-load problem and it is impacting performance.
Thank you for any further assistance,
Michael
Hi, Sarvesh thank you for any update you can provide. Please let me know if another ticket is needed.
Hi Mike,
Sorry for the inconvenience caused.
We'll validating your query with our development team. We'll update you shortly regarding an issue. If you would like to create a new ticket for easier follow-up, please feel free to do so. This will help us track and address your concerns more efficiently.
Regards,
Sarvesh
Great thank you for the update Sarvesh, your patience and professionalism are greatly appreciated. I will stick tight on this thread then if it's OK. :)
Hi Mike,
Based on your query, it seems that you are encountering an issue where the read
method is being called twice during component rendering. We suspect that this
could be due to the simultaneous execution of async functions. When a specific
task is delayed using the await keyword, it will be held for 1000ms before it
starts rendering. This could be the reason why the read method is being called
twice.
If you require some time to fetch data from the database
before rendering the grid, we suggest using the delay method before rendering
the grid. After the delay, you can proceed to render the grid using a Boolean
variable to ensure that the read method is called only once.
Regards,
Sarvesh
Hi Sarvesh thank you for your investigation and time looking into this.
To be certain, the Task.Delay call is meant to replicate a long-running SQL query. The issue is that SfGrid calls this method twice if there is a long delay in the processing, leading to two calls to the database. Shouldn't this boolean logic that you suggest be part of the SfGrid and not the developer's concern? This is what was done with the original (synchronous) fix, after all.
Thank you for any further consideration toward addressing this performance issue.
Hi Sarvesh,
I wanted to check in on this issue. Can you provide an example solution that demonstrates your suggestion so that the get data method is not called twice?
Thank you for any further assistance you can provide,
Michael
Hi Mike-E,
Based on your request, we have prepared a sample solution that demonstrates our
suggestion of calling the read method only once in a data manager. Please find
the attached sample for your reference.
If you have any further questions or concerns, please feel
free to let us know.
Regards,
Sarvesh
Hi Sarvesh,
Thank you for taking the time to provide a solution. Unfortunately, the solution you provided is synchronous, and the problem I am reporting now is in the asynchronous method:
public override async Task<object> ReadAsync(DataManagerRequest dm, string key = null)
The issue is when the `ReadAsync` takes significant time (e.g. database query call) the ReadAsync method ends up getting called twice by the SfGrid.
Please let me know if I can further assist in explaining the issue.
Thank you,
Michael
Hi Sarvesh I wanted to check in on this performance issue that is making two calls to the database when it occurs. Have you been able to see this in the solution I provided earlier?
Thank you for any assistance you can provide.
Hi Mike-E,
Sorry for the delay and inconvenience caused.
We have thoroughly investigated the issue you reported regarding the
asynchronous method "ReadAsync" and the behavior of the data manager.
After carefully reviewing your query and conducting tests using the provided
sample, we have confirmed that the "ReadAsync" method does indeed
call the data manager only once. We have attached a modified sample and a video
demonstration to showcase this behavior.
Upon further analysis, we have identified a potential cause
for the reported issue. It appears that the problem arises when the Task.Delay
method is invoked within the Read/ReadAsync method. This can result in the data
manager being called twice, leading to the undesired behavior you experienced.
To resolve this issue, we recommend removing the Task.Delay method from your
project. By doing so, you can overcome the reported problem and ensure that the
data manager is called only once, as intended.
Regards,
Sarvesh
Hi Sarvesh,
Thank you for your reply and investigation. Please note that your CustomAdaptor does not use asynchronous methods and in fact runs 100% synchronously, thereby avoiding the reported issue. Note that I receive the following warning about the `async` keyword via ReSharper analysis:
If you can, please kindly update your sample to use an EntityFramework Core DbContext or simply make a call to an external resource such as a database or web service. You should plainly see the issue under such circumstances.
The Task.Delay is meant to emulate a call to the database. Can you confirm this scenario, please? I can confirm that I am seeing two calls to the database because data manager is calling ReadAsync twice.
Thank you for your continued assistance,
Michael
Hi Mike-E,
From your query, we have prepared a sample using Entity Framework and DbContext
that runs asynchronously. However, we observed that the read method is called
only once from our end. In order to further investigate and address your
specific issue, we kindly request you to share your entire project with us.
This will enable us to validate the problem at our end and provide an accurate
solution. We have attached a sample for your reference, and we look forward to
assisting you further.
Regards,
Sarvesh
Thank you very much for your continued investigation Sarvesh. I found several issues with your SLN:
Attachment: EFGrid_8b1b4faa.zip
Hi Sarvesh, I wanted to check in with you as I did not hear back from you regarding this performance issue. Can you confirm the multiple calls via page load in the solution I provided you?
Please let me know if I can provide any further information, and I will assist you.
Hi Mike-E,
Sorry for the inconvenience caused.
Upon reviewing your last shared sample, we observed that the read method is
being called four times when invoking the SetPersistData method. However, we
would like to inform you that this issue has already been addressed in version
20.4.0.48.
Currently, we are in the process
of validating your sample to ensure that the issue has indeed been resolved. We
will thoroughly evaluate the sample and provide you with further details within
two business days. We kindly request your patience during this time. Thank you
for understanding.
Regards,
Sarvesh
Great thank you very much for the reply and continued investigation @Sarvesh.
Please note that the 20.4.0.48 fix only addressed the synchronous scenario. The issue we're exploring now is the asynchronous version.
Please further note that the solution I provided you has the following reference, which is greater than the above version:
```
<PackageReference Include="Syncfusion.Blazor.Grid" Version="22.1.37" />
```
Hi Sarvesh, I wanted to check in with you as it has been more than two business days. Please let me know if there is any further information that I can provide to help diagose this issue for you.
Hi Mike,
Apologize for the delay.
We are currently in the process of validating your query using different test
cases. We assure you that we will thoroughly evaluate the issue and provide
further information without any delay by July 21st. We appreciate
your patience during this time. Thank you for understanding.
Regards,
Sarvesh
> We assure you that we will thoroughly evaluate the issue and provide further information without any delay by July 21st
Hi Sarvesh it is July 22nd and I have not heard anything. Please let me know if I have misunderstood something about your pronouncement.
Hi Mike,
We sincere apologize for your frustration.
We have successfully replicated the mentioned issue at our end, wherein the
read method is called four times asynchronously while invoking the
SetPersistDataAsync method. We have thoroughly validated the reported issue
through various test cases involving dynamic column value binding. However, we
have not been able to determine the exact root cause of the problem yet.
We are currently investigating whether this issue is
specific to the component or a more general issue. we will provide an update
with a precise solution as soon as possible without any further delay. Your
cooperation is highly appreciated as we strive to find a solution to this
issue. Thank you for your patience and understanding.
Regards,
Sarvesh
Horray! Thank you very much for your patience and professionalism Sarvesh. :) I am very happy to hear that this issue has been confirmed. I look forward to any updates you may have going forward.
Hi Mike-e,
We have considered it as a bug and logged an issue “SetPersistDataAsync method invokes Asynchronous Read method Multiple Times” for the same. Thank you for taking the time to report this issue and helping us to improve our product. At Syncfusion, we are committed to fix all validated defects (subject to technological feasibility and Product Development Life Cycle) and this fix will be included in any of our upcoming patch release. We'll update once, when patch get rolled out.
You can now track the current status of your request, review the proposed resolution timeline, and contact us for any further inquiries through this link.
Disclaimer: “Inclusion of this solution in the weekly release may change due to other factors including but not limited to QA checks and works reprioritization”
Until then we appreciate your patience.
Regards,
Sarvesh
Yay, this really made my day! Thank you Sarvesh and team I greatly appreciate all your efforts out there. You really support your product excellently, which is what really matters in the end. Be proud!
Thank you for the acknowledgement. We will get back once it is fixed.
Hi Mike-e,
We are glad to announce that, we have included the issue “SetPersistDataAsync method invokes Asynchronous Read method Multiple Times” in our latest release. So please upgrade to our latest version of Syncfusion NuGet package to resolve the reported issue. Please find the Nuget package for latest fixes and features from below.
Nuget : https://www.nuget.org/packages/Syncfusion.Blazor.Grid
We thank you for your support and appreciate your patience in waiting for this release. Please get in touch with us if you would require any further assistance.
Regards,
Vignesh Natarajan