Palash01
Valued Contributor

Hey @rt-slowth 

The decision of whether to implement silver and gold data layers using tables or materialized views depends on several factors, and both approaches have their pros and cons. Here's a breakdown to help you choose:

Tables:

Pros:

  • Flexibility: Tables offer more flexibility for modifications and updates on the data itself.
  • Performance: Updating table data can be faster than refreshing a materialized view, especially for smaller datasets.
  • Fine-grained control: You have more control over data access and authorization on individual tables.

Cons:

  • Performance for querying: For large datasets, complex queries on tables can be slower than using materialized views pre-computing aggregations and joins.
  • Data consistency: Maintaining consistency between silver and gold layers can be more challenging with independent tables.

Materialized views:

Pros:

  • Query performance: Pre-computed data in materialized views often leads to faster query performance, especially for complex aggregations and joins on large datasets.
  • Data consistency: Materialized views automatically refresh based on their source tables, ensuring consistency between layers.

Cons:

  • Flexibility: The materialized view is based on the defined query, limiting modifications directly to the view data.
  • Maintenance: Refreshing materialized views can be resource-intensive, especially for large datasets and complex views.

So, which approach to choose?

Here's a general guideline:

  • Use tables:

    • If you need frequent updates to the data itself.
    • If data consistency is less critical or easily managed.
    • If query performance is not a major concern or the dataset is small.
  • Use materialized views:

    • If query performance for complex operations is crucial.
    • If data consistency between layers is critical.
    • If data updates are less frequent.

Regarding your question: Also, can you introduce how to optimize when putting a large amount of data into Redshift? I would encourage you to post this to a Redshift help community or StackOverflow where you can find more appropriate answers to this. Though I can provide a few insights while loading data keep a keen eye on 

  1. Data Compression (GZIP or LZO)
  2. Filter any unnecessary data that you don't need
  3. Work on schema optimization
  4. Proper use of Manifest files and Copy Activity
  5. Adjust your cluster size or concurrency settings
  6. Use Vaccum and Analyze commands to maintain table statistics and improve query performance.

Hope this helps, any follow-ups are appreciated.

 

Leave a like if this helps! Kudos,
Palash