A lot of new cars have throttle bodies (air control butterfly valves) that are opened and closed by a small electric motor instead of a cable connected to the foot pedal like older cars. After a battery goes dead, this motor needs to "find" where it is so it can be adjusted by the engine's computer. My 2005 Subaru just had this problem... and after some searching on the internet I found the solution. Many other manufactuer's cars have this same problem.
After changing the battery, turn the ignition switch on for 10 seconds berfore turning over the engine. This gives the electrical motor time to go to home position. After 10 seconds start the engine, let the engine idle with NO LOAD (AC, lights etc.) for 10 minutes so the computer can adjust the engine settings to optimum position.
This solved my problem on my Subaru for $0 and I am so glad a Subaru technician took the time to post the answer. Even if you have a new battery installed already, just disconnect the negative cable, wait 5 minutes and start over as I described above.
Has it had a chance to relearn its idle since disconnecting the battery cables ?
Its unlikely that it is related to getting a new battery. Make sure that during the process of replacing the battery that any emissions hoses or wiring were not disturbed or disconnected.
Computer reset
I meant to say "even after" replacing those parts.
No, that has nothing to do with idle speed.
Alternator needs replacing.
Not likely but possible.
I would check the battery voltage it should be 12.6 VDC at rest after 24 hours of no use. A low battery or loose alternator belt may cause the ecm to speed up the idle to charge the battery. Also check the Idle Air Control Valve. Clean it with Sea Foam or Carb Cleaner. improper ignition timing can also do it as well as a vacuum leak.
The engine computer has "lost" its idle memory. You need to unhook the battery for 5 minutes. That should reset it, and upon start up it should relearn idle positions.
Other than resetting the ECU, disconnecting the battery should not cause the bad idle. You have reset the ECU and it may need some time and driving cycles to idle correctly. But I am doubtful this is the problem. I would suspect this is just a coincidence, and you have another problem.
It may need replacing or it can be the alternator is overcharging the battery. Have the charging system checked out. The alternator should output from 13.5 to 15.5 volts with the engine running at idle.
if you are trying to change it while it is running it always needs an earth for the ecu otherwise there should not be any reason connected with the battery to cause idle problem