optimized queries for data  storing