Last Updated: 2024-05-13

Background

Welcome to the beginner's guide to Trino! Trino is a powerful distributed SQL query engine designed for running fast analytic queries against large datasets. Whether you're a data analyst, data scientist, or software engineer, Trino can help you query and analyze your data efficiently, without the need to move or copy it.

Scope of tutorial

In this tutorial, you'll get a taste of Trino without having to worry about a complicated setup process. You will begin by connecting to a configured Trino demo environment, then move on to running basic queries and viewing query details in the Trino web UI.

Learning objectives

Once you've completed this tutorial, you will be able to:

Prerequisites

Background

The Trino project provides a Docker container that allows you to easily start up a configured demo environment of Trino. With a few simple terminal commands, you can have Trino up and running to begin your exploration.

Step 1: Download Docker Trino container image

You can use the command shell of your choice for this tutorial. It was tested on a Mac, so the print screens you see will show a terminal window.

docker run -d -p 8080:8080 --name trino-trial trinodb/trino

Step 2: Connect to Trino server

The next command will connect the Docker container with the Trino image to the Trino server.

docker exec -it trino-trial trino

Background

Trino is an ANSI-SQL compliant engine. This makes it easy to query all of your data sources with the same language.

The Trino server used in this tutorial contains some sample TPC-H data which you'll query in this section.

Step 1: View available catalogs

A Trino catalog contains schemas and references a data source via a connector. You can easily view available catalogs with the SHOW CATALOGS command.

SHOW CATALOGS;

Step 2: View schemas and tables

In Trino, catalogs have a hierarchical structure in which a catalog can contain one or more schemas, and each of those schemas can contain one or more tables. You can use SQL to list the schemas and tables.

SHOW SCHEMAS IN tpch;
USE tpch.sf1;
SHOW TABLES;

Step 3: Query customer table

Let's run a query that returns the entire table so that you can learn to navigate the results in the CLI.

SELECT * FROM customer;

Notice the information that Trino provides at the end of each query. The number of nodes tells you how many workers were used to process the query. Ours used 1 worker. You'll also see the execution time, number of rows processed, and the speed at which they were processed.

Background

The Trino CLI provides some basic statistics for each query, but if you want to get even more detailed information, the Trino web UI is the place to go. There you'll find information such as the version of Trino running, the environment in which it is running, and how long the cluster has been active. Additionally, you'll be able to view active queries, query history, and the number of queued or blocked queries.

Step 1: Connect to Trino web UI

Step 2: Review Trino web UI landing page

After you log in to the Trino web UI, you are on a page that shows basic information about your Trino cluster.

Step 3: Review query details

The list of finished queries provides plenty of detailed information for each query. You can dig even deeper into each query by clicking on the Query ID link.

Tutorial complete

Congratulations! You have reached the end of this tutorial, and the end of this stage of your journey.

Now that you've learned a bit about how to use Trino, we encourage you to run your own queries in the Trino CLI, using your own SQL knowledge.

And if you're looking for an even easier way to use Trino in a fully-managed environment, check out Starburst Galaxy.

Continuous learning

At Starburst, we believe in continuous learning. This tutorial provides the foundation for further training available on this platform, and you can return to it as many times as you like. Future tutorials will make use of the concepts used here.

Next steps

Starburst has lots of other tutorials to help you get up and running quickly. Each one breaks down an individual problem and guides you to a solution using a step-by-step approach to learning.

Tutorials available

Visit the Tutorials section to view the full list of tutorials and keep moving forward on your journey!

Start Free with
Starburst Galaxy

Up to $500 in usage credits included

  • Query your data lake fast with Starburst's best-in-class MPP SQL query engine
  • Get up and running in less than 5 minutes
  • Easily deploy clusters in AWS, Azure and Google Cloud
For more deployment options:
Download Starburst Enterprise

Please fill in all required fields and ensure you are using a valid email address.