input: Write a function to optimize a Flask application for efficient performance by implementing the following techniques: using Redis for caching session and query performance, using uWSGI for Python applications, using gunicorn as WSGI server, using Flask-Compress extension for compression, using global variables where applicable, avoiding direct SQL queries and always using model methods, using query parameters in URLs instead of plain parameters, and using thread-local objects for performance.
  assert optimize_flask_app()==None
output: def optimize_flask_app():
      from flask import Flask, g
      from flask_compress import Compress
      from flask_redis import FlaskRedis
      from werkzeug.local import LocalProxy
  
      app = Flask(__name__)
      Compress(app)
      redis_client = FlaskRedis(app)
  
      @app.before_request
      def before_request():
          g.redis = redis_client
          g.thread_local = LocalProxy(lambda: g._thread_local)
          g._thread_local = {}
  
      @app.route('/query')
      def query():
          query_result = g.redis.get('cached_query')
          if not query_result:
              query_result = perform_query_via_model()
              g.redis.set('cached_query', query_result)
          return query_result
  
      @app.route('/session')
      def session():
          session_data = g.redis.get('session_data')
          if not session_data:
              session_data = fetch_session_data_via_model()
              g.redis.set('session_data', session_data)
          return session_data
  
      @app.route('/params')
      def params():
          param = request.args.get('param')
          return process_param_via_model(param)
  
      return None