Newsletter
Newsletter

Don’t use filter method on Large Datasets!

Scroll down
Emad Khan
Emad Khan
.𝐍𝐞𝐭 𝐂𝐨𝐫𝐞 | 𝐀𝐧𝐠𝐮𝐥𝐚𝐫 | 𝐍𝐮𝐱𝐭𝐉𝐒 | 𝐍𝐞𝐱𝐭𝐉𝐒 | 𝐍𝐞𝐬𝐭𝐉𝐒 | 𝐂𝐫𝐚𝐟𝐭 𝐒𝐜𝐚𝐥𝐚𝐛𝐥𝐞 & 𝐄𝐧𝐭𝐞𝐫𝐩𝐫𝐢𝐬𝐞 𝐋𝐞𝐯𝐞𝐥 𝐀𝐩𝐩𝐬🏆
  • Mobile
    +923452362514
  • Residence
    Pakistan

April 26, 2023

14:32

admin

I was working on the application in which I faced a performance issue, the issue was related to the fact that I used a grid in Angular application and on the grid I was triggering a click event on the td element of the table.

In the method attached to that td I was passing the index of the row and on the .ts file I used .filter method of array, later I realized that if the array size reaches to 5000 records then this will hit a performance bottleneck.

So I decided to use the for loop instead of filter and it boosted my performance to the level I can’t imagine. Here’s the code for your reference:

Posted in TechnologyTags:
© 2024 All Rights Reserved.
Write me a message

    * I promise the confidentiality of your personal information