This question is following to this answer point count in polygon by category
array_length(overlay_intersects('pointlayername',$id,filter:="fieldcontainingcategory"='nameofcategory'))
This answer worked form me if there is small polygon dataset, but if there is very big dataset then counting freezes.
But my polygon dataset consist of 500 000 (half million) polygon features. Can you offer an alternative solution for processing large volumes of data, the result of which would be analogous to the image.