> ## Documentation Index
> Fetch the complete documentation index at: https://docs.rapydo.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Introduction to execute query

### Introduction to Execute Query View

The **Execute Query View** is a pivotal feature for database administrators and developers who need to efficiently manage and interact with multiple databases simultaneously. This view is designed to streamline query execution, providing users with the ability to run custom SQL queries across one or more database instances. By offering a centralized and user-friendly interface, the Execute Query View eliminates the need for manual, repetitive execution of queries on individual databases, enhancing both efficiency and productivity.

In today's dynamic database environments, organizations often operate multiple database instances across various regions, handling diverse workloads. As a result, managing these databases can become complex, particularly when troubleshooting, performance optimization, or regular maintenance tasks are involved. The Execute Query View helps address these challenges by offering a powerful tool to execute queries in bulk, making it easier to gather critical insights, diagnose issues, and perform optimizations across multiple instances.

One of the primary benefits of the Execute Query View is the flexibility it offers. Users can input their own custom SQL queries to perform tailored operations, or they can choose from a range of predefined templates to run common database management tasks quickly. These templates cover a variety of use cases, such as identifying poor index usage, examining user privileges, optimizing tables, or detecting schema drifts. The availability of these templates reduces the time spent writing repetitive queries and ensures consistency across different operations, especially when managing multiple environments.

A standout feature of the Execute Query View is the ability to save queries as templates for future use. This is particularly useful for database administrators who regularly run the same queries for maintenance or monitoring purposes. Once saved, these templates can be executed with a few clicks, further streamlining the query execution process and reducing the possibility of human error when writing complex queries from scratch. This functionality is also useful for teams, as templates can be standardized and shared, ensuring that best practices are followed consistently across all database management activities.

Another critical aspect of the Execute Query View is its ability to display query results in a tabbed format, making it easy to manage multiple result sets. For example, if a query is executed on 10 different database instances, each result set will appear in its own tab, allowing users to quickly switch between databases and compare performance or identify discrepancies. This structure not only keeps the interface organized but also provides a comprehensive view of how queries are executed across the entire database landscape.

Furthermore, the view includes the capability to cancel long-running queries, which is essential in large-scale environments where performance issues may arise due to complex queries. The **Cancel Query** function ensures that administrators maintain full control over query execution, allowing them to stop any operations that may be consuming too many resources or affecting database performance.

The Execute Query View plays a vital role in database performance tuning and troubleshooting. For instance, templates like the **Top 10 Time-Consuming Queries** or **Poor Index Usage** help administrators quickly identify bottlenecks or inefficient queries that need optimization. Similarly, the **Schema Drift** template allows for the detection of differences in schema definitions across instances, ensuring that the database structure remains consistent and aligned with organizational standards.

In addition to these functionalities, the Execute Query View also provides enhanced security control through templates like **View User Privileges**, allowing administrators to quickly review and manage user access rights across databases. This feature is critical for maintaining data security and ensuring compliance with internal or external security policies.

In summary, the Execute Query View is an indispensable tool for database administrators looking to efficiently manage multiple database instances. Its flexibility, combined with powerful templates, the ability to save and reuse queries, and its organized tabbed interface, provides users with the tools they need to optimize performance, maintain consistency, and ensure the security of their database environments. Whether running ad-hoc queries, diagnosing performance issues, or performing regular maintenance, the Execute Query View is a vital component of any robust database management system.

***

## Key Technical Notes

**Read-Only Enforcement**
All queries executed through the Execute Query View are enforced as **read-only** at the database session level. MySQL sessions use `SET SESSION TRANSACTION READ ONLY` and PostgreSQL sessions use the equivalent session-level setting. DML and DDL operations (INSERT, UPDATE, DELETE, DROP, etc.) are not permitted.

**Row Limits**
If your query does not include a `LIMIT` clause, a default limit of **1,000 rows** is automatically applied. If your query already includes a `LIMIT` clause, that value is always respected — including values larger than 1,000 (e.g., `LIMIT 5000`). A message is shown in the result when a limit was automatically added.

**Canceling Queries**
There is no enforced execution timeout. Use the **Cancel** button to stop a long-running query at any time while it is executing.

**Querying RapydoDB**
In addition to your production database instances, you can select **Rapydo-DB** from the instance selector to run queries directly against RapydoDB — Rapydo's internal monitoring database. This is useful for exploring performance metrics, process history, and monitoring data.

**PostgreSQL: Database Name Required**
When one or more PostgreSQL instances are selected, a **"Connected to database"** field appears in the interface. This field must be filled before the **Execute** button becomes active. Use it to specify which database on the PostgreSQL server to connect to.

**Running a Selected Portion of a Query**
When text is selected in the SQL editor, the **Execute** button changes to **Run Selection**, allowing you to run only the highlighted portion of the query without executing the full script.

**Keyboard Shortcut**
Use **Cmd+Enter** (Mac) or **Ctrl+Enter** (Windows/Linux) to execute the query without clicking the Execute button.
