---
name: watsonxdata-exec_inspect_optimizer
title: Running queries from the Presto (C++) CLI or Query workspace
description: ''
last-updated: 2025-12-18
---

> ## Documentation Index
> The table of contents for this documentation set is at https://cloud.ibm.com/docs/watsonxdata?format=markdown
> The index for all IBM Cloud docs is at: https://cloud.ibm.com/docs/llms.txt
> Use these files to discover more information as needed.

{:javascript: #javascript .ph data-hd-programlang='javascript'}
{:java: #java .ph data-hd-programlang='java'}
{:ruby: #ruby .ph data-hd-programlang='ruby'}
{:php: #php .ph data-hd-programlang='php'}
{:python: #python .ph data-hd-programlang='python'}
{:external: target="_blank" .external}
{:shortdesc: .shortdesc}
{:codeblock: .codeblock}
{:screen: .screen}
{:tip: .tip}
{:important: .important}
{:note: .note}
{:deprecated: .deprecated}
{:pre: .pre}
{:video: .video}

# Running queries from the Presto (C++) CLI or Query workspace
{: #exec_inspect_optimizer}

IBM&reg; watsonx.data allows running SQL queries from Presto (C++) CLI or through the **Query workspace** with or without using **Query Optimizer**.

## About this task
{: #optimizer_runqueryabt}

You can select the option of running Presto (C++) CLI queries with or without using **Query Optimizer** operator in watsonx.data by using the following steps.

Running Presto (C++) queries:

1. Option 1: Running Presto (C++) queries by using **Query Optimizer**.

   a. Run the following command to enter into the directory `ibm-lh-client/bin`:
      ```bash
      cd ibm-lh-client/bin
      ```
      {: codeblock}

   b. Create an SQL file and export the file path to `LH_SANDBOX_DIR`. For example, with file name `sql-files`.
      ```bash
      export LH_SANDBOX_DIR=<path to sql-files>
      ```
      {: codeblock}

   c. Get the list of engine names and choose the one to be used. For example, engine name `engine1`.
      ```bash
      ./manage-engines --op=list
       export engine_name=engine1
      ```
      {: codeblock}

   d. Run the following command to run Presto (C++) queries using **Query Optimizer**.
      ```bash
      ./presto-run --engine=$engine_name --session is_query_rewriter_plugin_enabled=true -f $LH_SANDBOX_DIR/sql-files.sql
      ```
      {: codeblock}

   You must use either fully qualified name (3 part name such as `<catalog.schema.table>`) or 2 part name with the USE statement to qualify the catalog and schema.

   Examples: 3 part name: `select * from "catalog".schema.table;`

   2 part name: `use "catalog".schema; followed by select * from schema.table;`

2. Option 2: Running Presto (C++) CLI queries without using **Query Optimizer**.

   a. Run the following command to enter into the directory ibm-lh-client/bin:
      ```bash
      cd ibm-lh-client/bin
      ```
      {: codeblock}

   b. Create an SQL file and export the file path to `LH_SANDBOX_DIR`. For example, with file name `sql-files`.

      ```bash
      export LH_SANDBOX_DIR=<path to sql-files>
      ```
      {: codeblock}

   c. Get the list of engine names and choose the one to be used. For example with engine name `engine1`.
      ```bash
      ./manage-engines --op=list
      export engine_name=engine1
      ```
      {: codeblock}

   d. Run the following command to run Presto (C++) queries without using **Query Optimizer**.
      ```bash
      ./presto-run --engine=$engine_name --session is_query_rewriter_plugin_enabled=false -f $LH_SANDBOX_DIR/sql-files.sql
      ```
      {: codeblock}

      If the session parameter `is_query_rewriter_plugin_enabled` is set to `false`, you will not be able to execute the `ExecuteWxdQueryOptimizer` commands.
      {: note}

3. Follow the steps to get details of the queries and to verify if the queries executed are optimized:

   1. Log in to watsonx.data console.

   2. From the navigation menu, open **Infrastructure manager** page.

   3. Click on the Presto (C++) engine to open the component details page.

   4. Copy and browse open the host URL of the Presto (C++) engine from the details page to open the **Cluster Overview** external web page.

   5. Enter the username and password to login to the **Cluster Overview** page.

      Username : The username is `ibmlhapikey_<username>`.
      Password : The API key of the watsonx.data user. For more information about retrieving the API key, see [Generating the API key](https://cloud.ibm.com/docs/watsonxdata?topic=watsonxdata-con-presto-serv&format=markdown).

   5. Click on the **Query ID** you want to verify. This will open the **Query Details** page.

   6. Open the JSON file from the **Query Details** page to verify the parameter `is_query_rewriter_plugin_succeeded` value to be `true` or `false`. The optimized queries has the parameter value set to `true`.