Well, it would be possible to create two different profile-types. One for men and one for women. There you could automatically assign an avatar.
The pre-condition would be that gender-selection is mandatory when registering.
And a 3rd gender like "other" is no longer needed after it has pages.
Then a constant query would not be necessary.
Say the avatar is linked to the gender selection.
Well, I'll have a little play with it ...