add query by database as per settings