Optimize attach_foreignkey when theres a single value to lookup