API: SQL optimisation

https://github.com/marienfressinaud/FreshRSS/issues/13