SQL Query improvement and writing service for MobileAPpRegistration and MobileAppSession