Image compression may be lossy or lossless. Lossy methods are
especially suitable for natural images such as photographs (e.g JPEG
files) in applications where minor (sometimes imperceptible) loss of
fidelity is acceptable to achieve a substantial reduction in bit rate.
JPEG optimizing is considered to be a very efficient method to reduce JPEG file size while preserving the image quality. The goal is to reduce the size of photos without affecting their perceptual (noticeable) quality. The optimized image should look identical to the original image to humans, even if it was reduced to 30% of its original size or even less.
There are several tools for JPEG optimization, mostly command-line tools (libraries); the most popular ones are jpegtran & jpegoptim (Google PageSpeed recommends using them too).
If you're looking for a more user-friendly tool, I recommend using JPEGmini. It's an online service, and it's free for personal use. I don't know if it's the best tool to use in order to optimize thousands of photos (see FAQ), but from my experience, it's doing a great job optimizing JPEG photos.