<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Kriangsak Sumthong (Puk)</title>
    <description>The latest articles on Forem by Kriangsak Sumthong (Puk) (@kriangsak_sumthong).</description>
    <link>https://forem.com/kriangsak_sumthong</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1907427%2F43a6f42a-2815-4b7b-be8b-15634d043520.jpg</url>
      <title>Forem: Kriangsak Sumthong (Puk)</title>
      <link>https://forem.com/kriangsak_sumthong</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/kriangsak_sumthong"/>
    <language>en</language>
    <item>
      <title>AWS MWAA Serverless: Is It Worth the Switch from Provisioned?</title>
      <dc:creator>Kriangsak Sumthong (Puk)</dc:creator>
      <pubDate>Wed, 25 Feb 2026 15:58:29 +0000</pubDate>
      <link>https://forem.com/kriangsak_sumthong/aws-mwaa-serverless-is-it-worth-the-switch-from-provisioned-j0f</link>
      <guid>https://forem.com/kriangsak_sumthong/aws-mwaa-serverless-is-it-worth-the-switch-from-provisioned-j0f</guid>
      <description>&lt;p&gt;In the world of Data Engineering, building data pipelines is unavoidable. But what’s even more critical is the Orchestrator. Why? Because we can't (and shouldn't) manually trigger every step of a pipeline. Automation is a necessity.&lt;/p&gt;




&lt;p&gt;Today, we have a massive variety of orchestrators to choose from:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open Source: Apache Airflow (the most popular), Dagster, and Prefect.&lt;/li&gt;
&lt;li&gt;Managed/Closed Source: Cloud-native platforms like Google Cloud (Cloud Composer), Microsoft Azure, and Databricks.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fctkrrwdfx9h8ai3q1tij.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fctkrrwdfx9h8ai3q1tij.webp" alt=" " width="800" height="444"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then there’s Amazon Web Services (AWS) with its managed Airflow offering: Amazon MWAA.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Arrival of AWS MWAA Serverless
&lt;/h2&gt;

&lt;p&gt;At the end of 2025, AWS introduced MWAA Serverless. The core concept is simple: allowing Data Engineers to focus on workflows without worrying about infrastructure management.&lt;/p&gt;

&lt;p&gt;In the Provisioned version (non-serverless), AWS spins up dedicated infrastructure behind the scenes. This means you incur costs as long as the environment is active, even if no tasks are running. MWAA Serverless aims to change that.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyn3rvkqk7vsocjw3k4jt.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyn3rvkqk7vsocjw3k4jt.webp" alt=" " width="800" height="449"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;*Orchestration on AWS: MWAA vs. Step Functions&lt;br&gt;
It’s worth noting that MWAA isn’t the only orchestrator on AWS; AWS Step Functions is also a very popular choice. I’ll do a deep dive comparison in a future article, but for now, let's focus on MWAA.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A Quick Airflow Refresher&lt;br&gt;
Before we dive in, remember that in Airflow, we write scripts called DAGs (Directed Acyclic Graphs). A DAG defines the structure of your workflow, and inside each DAG are Tasks—the smallest unit of work.&lt;/p&gt;
&lt;/blockquote&gt;


&lt;h2&gt;
  
  
  Amazon MWAA Provisioned vs. Serverless
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Amazon MWAA Provisioned&lt;/strong&gt;&lt;br&gt;
This is essentially Apache Airflow deployed on AWS. AWS handles the compute, storage, and database, ensuring scalability, availability, and security. It feels exactly like the Airflow you’d deploy on your own server.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh6h32y1xn8alesqn68yk.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh6h32y1xn8alesqn68yk.webp" alt=" " width="800" height="389"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Amazon MWAA Serverless&lt;/strong&gt;&lt;br&gt;
This is the main highlight. With Serverless, you don’t set up infrastructure at all. You just drop your DAG into an S3 bucket and you're ready to go.&lt;/p&gt;

&lt;p&gt;The Catch: MWAA Serverless only reads YAML files. If you have existing Python-based DAGs, you must convert them to YAML first. (Don't worry, AWS provides a library for this!). Alternatively, you can build DAGs using a drag-and-drop GUI within Amazon SageMaker.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnvlmd1g56kd9miygspf2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnvlmd1g56kd9miygspf2.png" alt=" " width="800" height="460"&gt;&lt;/a&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  How to use Amazon MWAA Serverless
&lt;/h2&gt;

&lt;p&gt;There are two primary ways to create DAGs:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Method 1: Writing YAML DAGs manually&lt;/strong&gt;&lt;br&gt;
You can write your DAG in VS Code (or any editor) and upload it to S3.&lt;/p&gt;

&lt;p&gt;Example YAML DAG:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;simples3test:
  dag_id: simples3test
  tasks:
    list_objects:
      operator: airflow.providers.amazon.aws.operators.s3.S3ListOperator
      bucket: your-s3-bucket-name
      prefix: ""
      retries: 0
    create_object_list:
      dependencies:
        - list_objects
      operator: airflow.providers.amazon.aws.operators.s3.S3CreateObjectOperator
      data: Hello MWAA serverless
      s3_bucket: mwaa-serverless-test-cdlb
      s3_key: demo_text.txt
      replace: true
  schedule: 0 0 * * *
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9qprdu587zwxtt7k2wx4.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9qprdu587zwxtt7k2wx4.webp" alt=" " width="800" height="173"&gt;&lt;/a&gt;&lt;br&gt;
Once uploaded, you use the AWS CLI to register and execute the workflow:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Create workflow
aws mwaa-serverless create-workflow \
--name simple_s3_test \
--definition-s3-location '{ "Bucket": "your-s3-bucket-name", "ObjectKey": "path/simple_s3_test.yaml" }' \
--role-arn arn:aws:iam::111122223333:role/mwaa-serverless-access-role \
--region us-east-1

# Execute the workflow
aws mwaa-serverless start-workflow-run \
--workflow-arn arn:aws:airflow-serverless:us-east-2:111122223333:workflow/simple_s3_test-abc1234def \
--region us-east-1

# Update workflow if you have made any changes.
aws mwaa-serverless update-workflow \
--workflow-arn arn:aws:airflow-serverless:us-east-2:111122223333:workflow/simple_s3_test-abc1234def \
--definition-s3-location '{ "Bucket": "your-s3-bucket-name", "ObjectKey": "path/simple_s3_test.yaml" }' \
--role-arn arn:aws:iam::111122223333:role/mwaa-serverless-access-role \
--region us-east-1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fof3uytmmj7yy6qlqvj9z.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fof3uytmmj7yy6qlqvj9z.webp" alt=" " width="800" height="173"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Method 2: AWS SageMaker Workflow (GUI)&lt;/strong&gt;&lt;br&gt;
You can create workflows visually. In the MWAA Serverless console, click "Create workflow," and it will redirect you to the SageMaker Canvas/Workflow interface. You can drag and drop tasks like "Save file to S3" or "Trigger Glue Job." It’s incredibly convenient.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frqq7v3q2c8ef8qzh38my.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frqq7v3q2c8ef8qzh38my.webp" alt=" " width="800" height="382"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Extra: Converting Python DAGs to YAML&lt;/strong&gt;&lt;br&gt;
If you want to move your existing dag.py files to MWAA Serverless, AWS provides a converter library:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# AWS Python to Yaml Dag Converter for MWAA Serverless
pip install python-to-yaml-dag-converter-mwaa-serverless

# To convert .py to .yaml
dag-converter convert &amp;lt;python-dag-file&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa7mow4jeurihes4q9gk5.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa7mow4jeurihes4q9gk5.webp" alt=" " width="800" height="390"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Same Name, Different Game?
&lt;/h2&gt;

&lt;p&gt;While "Serverless" sounds like an upgrade, it is fundamentally different from the standard Airflow experience.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Differences &amp;amp; Limitations&lt;/strong&gt;:&lt;br&gt;
Limited Operators: MWAA Serverless focuses almost exclusively on AWS Operators (e.g., S3, Bedrock, Batch, Glue). Classic operators like PythonOperator or BashOperator are not supported. This is because AWS wants the heavy lifting (compute) to happen in other services, not within the serverless orchestrator itself.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Missing Parameters&lt;/strong&gt;: Many standard Airflow parameters are unavailable. If you rely on things like email_on_failure, catchup, or on_success_callback, you’ll need to rethink your logic using other AWS services (like SNS for notifications).&lt;/p&gt;




&lt;h2&gt;
  
  
  Final Verdict
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Go with MWAA Serverless if&lt;/strong&gt;: You are building a "pure" AWS workflow, you want something easy to set up, and you prefer a GUI or simple YAML definitions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Stay with MWAA Provisioned if&lt;/strong&gt;: You are migrating a complex, existing Airflow environment. If your DAGs use dynamic tasks, DAG-trigger-DAG patterns, or custom Python logic within the operators, Serverless will be more of a headache than a help.&lt;/p&gt;

&lt;p&gt;MWAA Serverless and Provisioned share a name and a concept, but they serve very different use cases. Choose the one that fits your architecture, not just the "Serverless" buzzword!&lt;/p&gt;




&lt;p&gt;REF:&lt;a href="https://docs.aws.amazon.com/mwaa/latest/mwaa-serverless-userguide/mwaas-concepts.html" rel="noopener noreferrer"&gt;https://docs.aws.amazon.com/mwaa/latest/mwaa-serverless-userguide/mwaas-concepts.html&lt;/a&gt;&lt;br&gt;
🌐 Note: This article was translated from Thai with the help of AI to share these insights with the global community. You can find the original Thai version on my page, here: &lt;a href="https://clouddatalabor.com/2026/02/25/can-amazon-mwaa-serverless-replace-amazon-mwaa-provisioned/" rel="noopener noreferrer"&gt;Clouddatalabor&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Happy Coding!&lt;br&gt;
Follow me for more insights on Cloud, Data, and AI at Clouddatalabor.&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>aws</category>
      <category>mwaa</category>
      <category>dataengineering</category>
    </item>
    <item>
      <title>View vs. Materialized View | A Beginner’s Guide with AWS Athena &amp; Redshift</title>
      <dc:creator>Kriangsak Sumthong (Puk)</dc:creator>
      <pubDate>Mon, 24 Mar 2025 15:43:10 +0000</pubDate>
      <link>https://forem.com/aws-builders/view-vs-materialized-view-a-beginners-guide-with-aws-athena-redshift-5cbl</link>
      <guid>https://forem.com/aws-builders/view-vs-materialized-view-a-beginners-guide-with-aws-athena-redshift-5cbl</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;View vs. Materialized View: What are the differences between these two, and let's try creating them on Redshift and Athena.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  What is a View Table?
&lt;/h2&gt;

&lt;p&gt;Normally, when querying data from a database or warehouse, we retrieve it directly from the table, right? However, if we need to repeatedly use the same query or if we need to use the query we wrote in other places, such as in the backend, ETL, or other ELT processes, we have to include the SQL we wrote. Now, imagine that the SQL we wrote is over 100 lines long. What happens? It's messy! Managing the script becomes difficult.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbdraawmphltvyxluis33.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbdraawmphltvyxluis33.png" alt="Example of some complicated query" width="800" height="877"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For example, as seen in the picture, this SQL is very long and complex. Copying it to different places or trying to write more code based on it becomes difficult and has a high chance of errors. This means that after copying, the syntax might get distorted.&lt;/p&gt;

&lt;p&gt;Therefore, something called a View table was created  to reduce the complexity of querying. As a result, the SQL we saw above will be reduced to what's shown in the example below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-- Example usecase, which is not really a good usecase LOL
SELECT * FROM company_table
WHERE member_id IN (SELECT employee_id FROM view_table)

-- If we not using view table
SELECT * FROM company_table
WHERE member_id IN (
SELECT employee_id 
FROM abc as a
LEFT JOIN efg as e
ON a.id = e.id
.
.
.
.
WHERE id IS NOT NULL);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It will be similar to querying a regular table, except that the data returned is the result of the query underlying that View table.&lt;/p&gt;

&lt;p&gt;However! Modern data warehouses have both View Tables and Materialized View Tables. What are the differences between these two? The next section will explain each type of View.&lt;/p&gt;

&lt;h2&gt;
  
  
  View Table
&lt;/h2&gt;

&lt;p&gt;View Table is a virtual representation of a table. In other words, when we create a View table, the physical data is not stored in the database. Instead, when we query it, the database executes the query that was used to create the View table. Therefore, no matter how many View tables we create, the storage space does not increase. Let's see how to create a View table.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-- syntax
CREATE [ OR REPLACE ] VIEW name [ ( column_name [, ...] ) ] AS query
[ WITH NO SCHEMA BINDING ] -- [] optional
-- example  use               
CREATE VIEW vw_myevents
AS
SELECT id FROM mockl;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After creating a View table and refreshing, we will find that the View table is located in the View section of both Redshift and Athena. Both services use similar syntax, which is CREATE VIEW.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ferrh9tijf43aoxvp8l19.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ferrh9tijf43aoxvp8l19.png" alt="Redshift views" width="313" height="334"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In Redshift, we can see the query underlying the View by right-clicking and selecting 'Show view definitions'. We can also edit it directly from there.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvj68o56k946gpbwhrgix.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvj68o56k946gpbwhrgix.png" width="708" height="299"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2vira1wv4qbij2lyf3yj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2vira1wv4qbij2lyf3yj.png" width="723" height="448"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In Athena, you can view and edit the query by right-clicking and selecting 'Show/edit Query'. You can also make additional edits directly from there.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdxb2fjjqw040wxuphbkl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdxb2fjjqw040wxuphbkl.png" width="800" height="368"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Materialized View
&lt;/h2&gt;

&lt;p&gt;Materialized View is a View that is similar to a regular View table, but with an added feature: Materialized View takes the data resulting from the query and creates a physical table that is stored in the database.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj08g81ft7utgy0e3zdfn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj08g81ft7utgy0e3zdfn.png" width="360" height="148"&gt;&lt;/a&gt;&lt;br&gt;
Querying data is faster with Materialized View compared to a regular View table. For example, if we have a join between table A and table B, with a regular View table, every time we query the view, the system has to process the join between table A and table B again. However, with Materialized View, the join processing is already done because the joined data is pre-stored.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fel15v8o6yhioepjn105f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fel15v8o6yhioepjn105f.png" width="800" height="334"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F565qcktu9g360jdgoz5z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F565qcktu9g360jdgoz5z.png" width="800" height="290"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's try creating a Materialized View in Redshift. (Athena cannot create Materialized Views because Athena is a serverless query engine and does not store any data. Therefore, it cannot create them. The workaround is to create a table from the query and store it in S3.🤓)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-- syntax
CREATE MATERIALIZED VIEW mv_name
[ BACKUP { YES | NO } ]
[ table_attributes ]
[ AUTO REFRESH { YES | NO } ]
AS query 

-- example use
CREATE MATERIALIZED VIEW "public"."mvw_myevent_demo"
AUTO REFRESH YES
AS
SELECT
    id, first_name, last_name
FROM
    "public"."mockl"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After refreshing the Editor page, you'll find that the Materialized View is now in the View section. As mentioned, Materialized View stores data in the database. Therefore, when you query SVV_TABLE_INFO (a table that stores information about system tables and user-defined tables), you'll see only the Materialized View, not the View table, and it also shows the data size.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F92zfjwp6wvfxzhv28dvn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F92zfjwp6wvfxzhv28dvn.png" width="800" height="308"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The limitations of Materialized View are quite significant. Here are some examples of what cannot be used to create Materialized Views:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Standard views or system tables and views&lt;/li&gt;
&lt;li&gt;Temporary tables&lt;/li&gt;
&lt;li&gt;User-defined functions&lt;/li&gt;
&lt;li&gt;ORDER BY, LIMIT, or OFFSET clauses&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Pros and Cons of View and Materialized View
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;View Pros:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Simplifies queries, reducing lengthy queries to just one line.&lt;/li&gt;
&lt;li&gt;Provides up-to-date data every time it's queried, reflecting the underlying data in the View (e.g., if there's no WHERE clause, you get the latest data).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;View Cons:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Modifying a View requires deleting and recreating it.&lt;/li&gt;
&lt;li&gt;Changes in the source tables of the View's query can break the View.&lt;/li&gt;
&lt;li&gt;While it provides fresh data, it cannot be indexed or optimized directly;&lt;/li&gt;
&lt;li&gt;optimization must be done on the underlying tables.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Materialized View Pros:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Faster query performance because it retrieves data from the pre-stored Materialized View, not the source tables.&lt;/li&gt;
&lt;li&gt;Reduces ETL/ELT steps and simplifies modifications compared to creating new tables via ETL/ELT.&lt;/li&gt;
&lt;li&gt;Redshift offers auto-refresh, updating data from source tables, eliminating the need for separate data update pipelines.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Materialized View Cons:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Increases database storage consumption, similar to creating a new table.&lt;/li&gt;
&lt;li&gt;Not suitable for real-time data with constant updates; better for batch processing (even with manual refresh).&lt;/li&gt;
&lt;li&gt;Cannot be created on Athena.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Regarding the selection of which to use, I have these general guidelines:
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;View:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If you want to avoid increasing storage costs.&lt;/li&gt;
&lt;li&gt;If you need to use it with real-time data.&lt;/li&gt;
&lt;li&gt;If the query is simple and not complex.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Materialized View:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If you want to improve query performance for dashboard displays, especially when pre-processing is required.&lt;/li&gt;
&lt;li&gt;To reduce processing overhead from complex queries, as Materialized View pre-processes and stores data as a physical table.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;Hope this help!&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;originated from my article in Thai: &lt;a href="https://clouddatalabor.com/2025/03/24/view-vs-materialized-view-a-beginners-guide-with-aws-athena-redshift/" rel="noopener noreferrer"&gt;https://clouddatalabor.com/2025/03/24/view-vs-materialized-view-a-beginners-guide-with-aws-athena-redshift/&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>aws</category>
      <category>redshift</category>
      <category>athena</category>
    </item>
  </channel>
</rss>
