Skip to main content

Write and run queries in PG Studio

Learn how to use the SQL editor in PG Studio to write, edit, and execute queries.

Write SQL manually

  1. In the SQL editor, enter your query.

    Use Tab to autocomplete

    Press the Tab key to autocomplete SQL keywords, table names, column names, and other database objects from your schema. When the autocomplete list is open, use the arrow keys to move between suggestions and press Enter or Tab to insert the selected suggestion. Press Esc to dismiss autocomplete.

  2. Click Run.

  3. View the results in the results panel.

The autocomplete feature helps you write queries faster by suggesting:

  • SQL keywords and clauses: SELECT, FROM, WHERE, JOIN
  • Table names from your selected schema
  • Column names from tables in your query
  • Database functions and operators

Run selected SQL

When working with multiple SQL statements, the editor runs one query at a time. It runs the query where your cursor is placed.

  1. In the SQL editor, place your cursor in the query to run.
  2. Click Run selected next to the active query.
  3. View the results in the results panel.

This is useful for:

  • Testing individual queries from a larger script
  • Iterating on a single query while keeping other statements in context
  • Testing each subquery independently before combining a complex query
  • Verifying data in a specific table without executing setup or cleanup statements

Execute queries

When you run a query, whether generated by the AI or written manually:

  • The editor executes it.
  • The results panel displays your query results.

Query execution limits

PG Studio applies these limits to query execution:

  • Single-statement validation: PG Studio allows only one SQL statement per execution.
  • Statement timeout: 30 seconds
  • Lock timeout: 10 seconds
  • Connection timeout: 10 seconds
  • Maximum result size: 5,000 rows
  • Rate limiting: One request every two seconds per user per service.