How to find a post with a specific custom field value?

I'm using custom fields in my implementation, and one defined field (let's call it resource_index) contains a numeric index value that's to be unique among all posts in a given site.

Given an index value, I'd like to be able to find out (a) if any post's resource_index custom field contains a matching index value, and (b) which post (by post ID) that is.

Obviously, I can iterate through all the posts, but I'm looking for something that's quick, hopefully blazing quick.

Any suggestions?


POST ID   resource_ID
22         5
23         7
24         2

If I pass 5 as a desired resource_ID, I'd get 22 back. If I pass 2, I'd get 24 back. And if I passed 12, I'd get false back.