How to get Attachments(image) with specific width\height ratio

The _wp_attachment_metadata stores serialized data. It’s not meant to be used directly in queries to match results. Instead hook add_attachment action and store original image’s dimensions into separate post meta properties. After you’re happy with how it works follow Rarst’s advice and find a way to walk all existent image attachments and generate those meta data for them also.