Skip to content

Profile Queries

After connecting your app to ReadySet, profile your app performance and identify queries to cache in ReadySet. Generally, it's best to focus on frequent queries that are too slow and/or that are putting unwanted load on your upstream database.

If you already have performance monitoring in place, use that tooling to identify queries that can benefit from caching in ReadySet. Otherwise, you can use ReadySet's own metrics endpoint to profile queries.

Enable ReadySet metrics

To enable ReadySet metrics, start ReadySet with the following options:

To include query-specific execution metrics, also pass:

Access ReadySet metrics

You can access ReadySet metrics at <metrics address>/metrics, where the metrics address is defined by the --metrics-address option (default: 0.0.0.0:6034/metrics).

Tip

When running ReadySet locally, you can usually access ReadySet metrics at https://127.0.0.1:6034/metrics in your browser.

Examine per-query metrics

ReadySet metrics are formatted for easy integration with Prometheus. However, the quickest way to examine per-query metrics is to use a simple metrics utility written in Python that queries the metrics endpoint and displays latencies for queries received by ReadySet.

  1. Download the metrics utility and its requirements.txt:

    curl -O "https://raw.githubusercontent.com/readysettech/docs/main/docs/assets/metrics/metrics.py"
    curl -O "https://raw.githubusercontent.com/readysettech/docs/main/docs/assets/metrics/requirements.txt"
    
  2. Install dependencies for the utility:

    pip3 install -r requirements.txt
    
  3. Set the HOST environment variable to the IP address/hostname portion of --metrics-address:

    export HOST="<metrics-host>"
    
  4. Run the script with

    python3 metrics.py --host=${HOST}
    

    You can filter the output of this script to show only queries displayed in SHOW PROXIED QUERIES or SHOW CACHES by passing the --filter-queries flag and piping the output of those ReadySet commands into the script like so:

    PGPASSWORD=noria psql --host=127.0.0.1 --port=5433 --username=postgres --dbname=noria -c "SHOW CACHES" | python3 metrics.py --filter-queries