First I tried to use normal PHP arrays (using integer as the key and amount of entries as the value), but I was not happy about performance, so I decided to look for more specialized data types. Though using them improved memory usage a little bit, but did not improve timings.
Also I decided to use pagination because the amount of duplicates is huge and browser was not happy about it
The better solution would be to use queries and chunk by chunk process the information on background
Kind of surprisingly, but on linux server the performance became much better
| Integer | Count of duplicates |
|---|---|
| 1002894 | 2 |
| 1002914 | 3 |
| 1003077 | 2 |
| 1003536 | 2 |
| 1003609 | 2 |
| 1003634 | 2 |
| 1003772 | 2 |
| 1003880 | 2 |
| 1004320 | 2 |
| 1004486 | 2 |
| 1004867 | 2 |
| 1005068 | 2 |
| 1005109 | 2 |
| 1005834 | 2 |
| 1005892 | 2 |
| 1005898 | 2 |
| 1006450 | 2 |
| 1006572 | 2 |
| 1006693 | 2 |
| 1006989 | 3 |