If O2 sensor is original change it, just the one by exhaust manifold not the one behind Cat Converter.
P0171 means computer is running the engine Rich because O2 is seeing too much Oxygen in the exhaust(Lean), so MPG will be low
Make sure you don't have an exhaust manifold leak, that sucks in oxygen and O2 will report false Lean.
Older O2's, over 100,000 miles, start to fail Lean, so computer runs engine richer, so worth while to replace O2 sensor when you get over 100k miles, 150k for sure
Also Clean the MAF sensor, always, anytime you have a Lean or Rich code