SQL optimization

Signed-off-by: Emilien Kenler <hello@emilienkenler.com>
SQL Optimization

Signed-off-by: Emilien Kenler <hello@emilienkenler.com>