
Before you begin
- Labs create a Google Cloud project and resources for a fixed time
- Labs have a time limit and no pause feature. If you end the lab, you'll have to restart from the beginning.
- On the top left of your screen, click Start lab to begin
Create a baseline data set
/ 50
Testing the Columnar Engine
/ 50
AlloyDB for PostgreSQL is a fully managed PostgreSQL-compatible database service for your most demanding enterprise database workloads. AlloyDB combines the best of Google with one of the most popular open-source database engines, PostgreSQL, for superior performance, scale, and availability.
The Columnar Engine can significantly accelerate the speed at which AlloyDB processes SQL scans, joins, and aggregates. The Columnar Engine provides the following features: 1) a column store that contains table data for selected columns, reorganized into a column-oriented format and 2) a columnar query planner and execution engine to support use of the column store in queries.
In this lab, you explore features of the AlloyDB Columnar Engine.
In this lab, you learn how to perform the following tasks:
Read these instructions. Labs are timed and you cannot pause them. The timer, which starts when you click Start Lab, shows how long Google Cloud resources are made available to you.
This hands-on lab lets you do the lab activities in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials you use to sign in and access Google Cloud for the duration of the lab.
To complete this lab, you need:
Click the Start Lab button. If you need to pay for the lab, a dialog opens for you to select your payment method. On the left is the Lab Details pane with the following:
Click Open Google Cloud console (or right-click and select Open Link in Incognito Window if you are running the Chrome browser).
The lab spins up resources, and then opens another tab that shows the Sign in page.
Tip: Arrange the tabs in separate windows, side-by-side.
If necessary, copy the Username below and paste it into the Sign in dialog.
You can also find the Username in the Lab Details pane.
Click Next.
Copy the Password below and paste it into the Welcome dialog.
You can also find the Password in the Lab Details pane.
Click Next.
Click through the subsequent pages:
After a few moments, the Google Cloud console opens in this tab.
Cloud Shell is a virtual machine that is loaded with development tools. It offers a persistent 5GB home directory and runs on the Google Cloud. Cloud Shell provides command-line access to your Google Cloud resources.
Click Activate Cloud Shell at the top of the Google Cloud console.
Click through the following windows:
When you are connected, you are already authenticated, and the project is set to your Project_ID,
gcloud
is the command-line tool for Google Cloud. It comes pre-installed on Cloud Shell and supports tab-completion.
Output:
Output:
gcloud
, in Google Cloud, refer to the gcloud CLI overview guide.
In this lab environment, an AlloyDB cluster and instance are provisioned when you start the lab.
On the AlloyDB page, there is a cluster named lab-cluster and an instance named lab-instance. The instance takes a few minutes to be fully created and initialized.
Please wait until you see a green checkmark (status of Ready) beside the instance named lab-instance in the Resource name column before you proceed to the next step.
10.100.0.2
) to a text file so that you can paste the value in a later step. Do not include the colon and port number (:5432
).To evaluate the capabilities of the Columnar Engine, you need a dataset of significant size against which to measure performance. In the next steps, you utilize the PostgreSQL tool pgbench to generate a synthetic dataset to evaluate the Columnar Engine.
From the Navigation menu (), under Compute Engine, click VM instances.
For the instance named alloydb-client, in the Connect column, click SSH to open a terminal window.
Set the following environment variable, replacing ALLOYDB_ADDRESS with the Private IP address of the AlloyDB instance.
The largest table pgbench_accounts will be loaded with 50 million rows. The operation takes a few minutes to complete.
Click Check my progress to verify the objective.
For evaluation purposes, you can run a very simple query that performs seq scans and then use explain query plans for that query before and after adding the test table to the Columnar Engine.
Note: This sample query has a limit of 20 returned rows because this is for demonstration purposes.
In the results pay particular attention to the Planning Time and Execution Time values. In the sample output, the Planning Time is 0.117 milliseconds and the Execution Time is 11014.169 milliseconds or 11.014 seconds. Your values should appear similar to those in the sample output but will vary because of the random nature of data generation.
Copy the values for Planning Time and Execution Time from your run to text file so that you may compare them later with the results after the Columnar Engine is enabled. You may also copy the entire query plan results to a text file.
Press the Q key to close the query plan.
In this task, you examine the Columnar Engine database flag in your instance.
In the Google Cloud Console, click on the Navigation menu () > View all products. Then, under Databases, select AlloyDB.
On the row for the instance named lab-instance, click on Actions (icon with three vertical dots), and then click Edit.
Expand the section named Advanced Configuration Options.
Under Flags, click Add a database flag.
Click Choose a flag to browse the list of available flags to get a sense of the supported options.
Notice that the flag named google_columnar_engine.enabled is already enabled (status of on). You will not add an additional flag as part of this lab.
Continuing from the previous section, in this task, you set up a database extension to fully enable the Columnar Engine feature for your AlloyDB cluster.
Unlike configuring a flag, you must connect to your instance via the psql client to enable a database extension.
Return to the alloydb-client shell. The psql client should still be active. If not, reconnect using the instructions in Task 1.
Ensure that you are connected to the postgres database by running the following query.
Because your main table ( pgbench_accounts) is relatively small, you can add it directly to the Columnar Engine for evaluation. In a real-life deployment you would utilize the Columnar Engine's recommendation framework to automatically identify the most heavily used columns across all tables that would provide the most benefit from being managed by the engine.
In the results pay particular attention to the Planning Time and Execution Time values. In the Post-Columnar Engine sample, the Planning Time is 2.022 milliseconds and the Execution Time is 78.804 milliseconds. Your values should appear similar to those in the sample output but will vary because of the random nature of data generation.
From the samples provided, the difference between the Execution Time Pre-Columnar Engine and Post-Columnar Engine is 10935.365 ms or 10.9 seconds. That is a decrease of 141 times. In the Post-Columnar Engine sample, also note that over 4.5 million rows were aggregated using a columnar scan rather than the core database engine.
Click Check my progress to verify the objective.
You have now explored powerful features of the AlloyDB Columnar Engine.
...helps you make the most of Google Cloud technologies. Our classes include technical skills and best practices to help you get up to speed quickly and continue your learning journey. We offer fundamental to advanced level training, with on-demand, live, and virtual options to suit your busy schedule. Certifications help you validate and prove your skill and expertise in Google Cloud technologies.
Manual Last Updated October 28, 2024
Lab Last Tested August 9, 2023
Copyright 2025 Google LLC All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.
Este contenido no está disponible en este momento
Te enviaremos una notificación por correo electrónico cuando esté disponible
¡Genial!
Nos comunicaremos contigo por correo electrónico si está disponible
One lab at a time
Confirm to end all existing labs and start this one