Remove SQL performance bottlenecks