I think comparing yourself to others CAN be productive, but it has to come from a healthy place.
For example, I've been in business for nearly 10 years now. Let's say that I was frustrated with the businesses growth and so I start wondering what Jimmy, Danny, and Mary, who are also gym owners and have been doing this nearly as long as I have, are doing from a monthly gross revenue stand point.
I reach out to them and find out that they're doing 50% more on a monthly basis than I am.
This can go a few ways here, but I'm going to focus on the most likely two ways it would go.
1) "How in the hell are they doing that?!?! I NEED to get that point if I'm ever going to be successful!"
2) I get curious. What are they doing better than I am and how can I apply that to what I do so that I can get better?
The former displays an outlook that all I am basing my level of "success" on is the gross revenue generation. This is a dangerous game. What happens when/if I get my gross revenue up to what Jimmy, Danny, and Mary are producing only to find out that they've accelerated their businesses to another 20% growth?
I'm probably going to chase that number and if it's not that number then I'll find some other metric to chase in order to validate my self-worth and perception of success.
The latter scenario showcases a mindset of personal growth that is spurred by curiosity, internal motivation, and a genuine desire to get better for not only my own growth, but everyone around me.
I'm not saying don't compare yourself to others, but I do encourage you to challenge the underlying meaning of the need to compare yourself to others.
If it's unhealthy (i.e. creates anxiety, poor self-image, etc.) then find ways to sort that out otherwise you will carry that burden with you forever in many aspects of your life.