SQL Optimization and SNIFF