Sql is confusing.
SELECT COUNT(id) FROM Documents WHERE EXTRACT(YEAR FROM date)=2000;
runs in 0.03 seconds
SELECT DISTINCT EXTRACT(YEAR FROM date) AS Year FROM Documents ORDER BY Year;
runs in about 0.1 second
Every way I have come up with to combine the two takes minutes.