When you begin entering recipient's e-mail addresses in the "To" field for new messages in Apple's Mail client, the program will attempt to autocomplete them to make addressing your messages easier. This usually is a pretty quick process; however, there are some instances where slowdowns can occur. When this happens you might enter a few characters of a contact's name or e-mail address, and Mail will then show the spinning color wheel and not respond, which may occur for a number of minutes.
If this happens you can likely fix the problem by checking either your address book, Mail's previous recipients list, or even directory server settings on your system. In addition you might also look at some of Mail's settings and preferences.
Apple's Address Book is a local directory that applications like Mail will tap into for contact information. If there is corruption in the contacts database then one option you can do is rebuild it by exporting your contacts and then re-importing them. To do this, open Address Book and choose the "Address Book Archive" in the File > Export menu. Save the archive somewhere safe like your desktop, and then delete all the entries in your address book. Next, go to the /username/Library/Application Support/AddressBook/ folder and remove the contents of this folder (move them to the desktop). Then select "Import" from Address Book's File menu and import the previously saved Address Book archive to set up your contacts again.
Mail's Previous Recipients
Another source for address autocompletion in OS X is Mail's previous recipients list, which is a list of non-junk addresses that have sent you e-mail. This list can be cleared by going to the "Window" menu in Mail and choosing the "Previous Recipients" option, and then selecting all or a subset of addresses and clicking the "Remove from list" button. This list can also be cleared by going to the /username/Library/Application Support/AddressBook/ folder and removing the file containing the text "MailRecents" in its name.
Network directory server
The next option for mail autocomplete options is the use of a network directory server, which unlike the Address Book and Mail's Previous Recipients databases is a remote option that can provide large numbers of contacts for Mail to use. If you have a directory server set up and Mail cannot properly access it, then the program may pause while it attempts to establish a connection. Additionally, if there are problems with the directory server's configuration then Mail may hang.
To check for whether Mail is using a network server, go to the "Composing" section of Mail's preferences and click on the "Configure LDAP" button. Then see whether you have any directory servers available. If so then you can either uncheck them or remove them from this list, or edit them so they are configured properly.
Check and reset Mail preferences
A last option for addressing this issue is to change or reset some of Mail's preferences. The key setting to adjust is the address autocompletion option, which is in the "Composing" section of Mail's preferences, next to the "Configure LDAP" button. Uncheck this option to see if the hangs go away when entering email addresses. In addition, you can try removing Mail's entire preferences file to have it be rebuilt from default settings--sometimes odd problems with preferences files can cause bizarre behavior. Mail's preferences file is called "com.apple.Mail.plist" and is located in the /username/Library/Preferences folder. Remove the file and relaunch Mail, and after entering your account information again then try autofilling e-mail addresses.