OCSInventory-NG / OCSInventory-Server

Communication server of OCS Inventory
http://www.ocsinventory-ng.org/
GNU General Public License v2.0
344 stars 139 forks source link

fixed heavy DB load by prevent macaddr query #395

Closed EldoBam closed 1 year ago

EldoBam commented 2 years ago

Status :

READY

Description :

I fixed an issue you'll face if you have a huge amount of clients with virtual network cards and its macaddr '00:00:00:00:00:00'.

How the behaviour is before this commit: --> 40k clients with 5 virtual nic adapter --> every time when sub _duplicate_detect was called this sub queried the database 5 times "give me all networks with mac addresses 00:00:00:00:00:00" wich doesn't have my hardware_id --> this causes the database to return around 200k entries, five times... --> .. so the frontend has to loop 1M entries and calls the funtion already_in_array 1M times

How the behaviour is after my commit: --> 40k clients with 5 virtual nic adapter --> every time when sub _duplicate_detect is called this sub queries the database 0 times "give me all networks with mac addresses 00:00:00:00:00:00" wich doesn't have my hardware_id --> this causes the database to return exactly 0 entries, zero times... --> .. so the frontend has to loop zero entries and calls the funtion already_in_array zero times

So the only thing I changed, was to check the blacklist before the database is queried. In your logic the sub first queries the database and checking each result of an blicklisted macaddr if its on the blacklist.

--> Sorry the last pull request I created had a bug o((⊙﹏⊙))o.

greetings eldo

EldoBam commented 2 years ago

This Pull Request fixes #396

gillesdubois commented 2 years ago

Hi @EldoBam

We are going to review PR in the following days :) Thanks for your contribution !

Regards, Gilles.

EldoBam commented 2 years ago

Hi Gilles,

thank you for your response.

Regards, Timo

charleneauger commented 1 year ago

Hi @EldoBam ,

I tested your PR and it works :-) Thanks for your contribution !

Best regards, Charlene

EldoBam commented 1 year ago

@charleneauger

Thank's for implementing :)

I will pull all the changes and set it up in our test-environment, where 40k clients will report :) Let's see if I can go with the latest version without modifications, otherwise I will come along with some other improvements.

best regards