updated sql queries for reading log table from db