# How backend works when joining datasets

**URL:** <https://community.amazonquick.com/t/how-backend-works-when-joining-datasets/36062>\
**Category:** Q&A\
**Tags:** dataset, Business-Intelligence-Engineer, quick-sight\
**Created:** [September 25, 2024, 12:15am UTC](https://community.amazonquick.com/t/how-backend-works-when-joining-datasets/36062 "2024-09-25T00:15:04Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![hoyeon](https://avatars.discourse-cdn.com/v4/letter/h/dfb087/32.png) [@hoyeon](https://community.amazonquick.com/u/hoyeon)\
**Post date:** [September 25, 2024, 12:15am UTC](https://community.amazonquick.com/t/how-backend-works-when-joining-datasets/36062/1 "2024-09-25T00:15:04Z")

</div>

On the dataset page, users can join multiple Quick Sight datasets with inner/left/right/full joins.  
What is happening when users join two different mode datasets, SPICE and Direct Query datasets on the UI?  
Does Quick Sight run a SQL query for the joins? Does it run a direct query on the underlying database for the Direct Query dataset and joins the data with SPICE afterwards?

I would like to know what happens on the backend side for this join.

---

<div class="post-metadata">

**Author:** ![shravya](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/shravya/32/9969_2.png) [@shravya](https://community.amazonquick.com/u/shravya)\
**Post date:** [September 25, 2024, 2:15am UTC](https://community.amazonquick.com/t/how-backend-works-when-joining-datasets/36062/2 "2024-09-25T02:15:17Z")

</div>

Hi @hoyeon,

Yes, Quick Sight effectively runs a SQL-like query in the background for Direct Query datasets. However, it doesn’t run a SQL query in the traditional sense for SPICE datasets since SPICE is an in-memory engine. The join happens after Quick Sight retrieves the Direct Query data and combines it with SPICE-stored data in-memory.

Just a reference → [Joining data - Amazon QuickSight](https://docs.aws.amazon.com/quicksight/latest/user/joining-data.html)

Let me know if that helps.

Thank you,  
Shravya

---

<div class="post-metadata">

**Author:** ![hoyeon](https://avatars.discourse-cdn.com/v4/letter/h/dfb087/32.png) [@hoyeon](https://community.amazonquick.com/u/hoyeon)\
**Post date:** [September 25, 2024, 3:48pm UTC](https://community.amazonquick.com/t/how-backend-works-when-joining-datasets/36062/3 "2024-09-25T15:48:27Z")

</div>

1. When users view the dashboard that is generated from the dataset which has joins with Direct query datasets and SPICE datasets in Quick Sight, does it always run each Direct query dataset first and combine them in-memory?
2. What is the timeout limit for joins?
3. What is the language to query data from in-memory data if that’s not SQL? I am curious how it efficiently retrieves data for dashboarding in seconds.

---

<div class="post-metadata">

**Author:** ![shravya](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/shravya/32/9969_2.png) [@shravya](https://community.amazonquick.com/u/shravya)\
**Post date:** [September 28, 2024, 11:52am UTC](https://community.amazonquick.com/t/how-backend-works-when-joining-datasets/36062/4 "2024-09-28T11:52:17Z")

</div>

Hello @hoyeon

Thank you for the follow up questions.

**Timeout** : Quick Sight enforces a 2-minute timeout for visual generation. If the Direct Query exceeds this time, the visual may fail to load.

I would suggest you to have a look on these blogs, they are really very insightful and provides the required answers.

1. [Best practices for Amazon QuickSight SPICE and direct query mode](https://community.amazonquick.com/t/best-practices-for-amazon-quicksight-spice-and-direct-query-mode/32717)
2. [SPICE and Direct Queries for Enhanced Data Analytics and Visualization](https://www.cloudthat.com/resources/blog/spice-and-direct-queries-for-enhanced-data-analytics-and-visualization)
3. [Joining across data sources on Amazon QuickSight | AWS Big Data Blog](https://aws.amazon.com/blogs/big-data/joining-across-data-sources-on-amazon-quicksight/)

Let me know if these helps.

Thank you,  
Shravya

---

<div class="post-metadata">

**Author:** ![Sanjeeb2022](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/sanjeeb2022/32/20947_2.png) [@Sanjeeb2022](https://community.amazonquick.com/u/Sanjeeb2022)\
**Post date:** [September 28, 2024, 1:23pm UTC](https://community.amazonquick.com/t/how-backend-works-when-joining-datasets/36062/5 "2024-09-28T13:23:36Z")

</div>

In addition to @shravya , when you join a spice data set and with direct query data set, the result is always store in SPICE. Please check this as well.

Regards - Sanjeeb

---

<div class="post-metadata">

**Author:** ![hoyeon](https://avatars.discourse-cdn.com/v4/letter/h/dfb087/32.png) [@hoyeon](https://community.amazonquick.com/u/hoyeon)\
**Post date:** [September 30, 2024, 3:14pm UTC](https://community.amazonquick.com/t/how-backend-works-when-joining-datasets/36062/6 "2024-09-30T15:14:05Z")

</div>

@Sanjeeb2022  
Q1: If joined output is always stored in SPICE, when does it refresh data for direct query dataset that used in joins?

Q2: If a dataset enabled RLS rules, and joins with other dataset, does the joined dataset also convey/apply the RLS rules for the derived output?  
Does joining logic care for RLS rules for the base dataset?

---

<div class="post-metadata">

**Author:** ![hoyeon](https://avatars.discourse-cdn.com/v4/letter/h/dfb087/32.png) [@hoyeon](https://community.amazonquick.com/u/hoyeon)\
**Post date:** [October 1, 2024, 12:46am UTC](https://community.amazonquick.com/t/how-backend-works-when-joining-datasets/36062/7 "2024-10-01T00:46:43Z")

</div>

Here are my findings.

1. CLS enabled datasets cannot be used for join
2. RLS enabled SPICE datasets are changed to Direct Query mode in joins. It fails when joining RLS enabled dataset with other datasets. (Error message: Can’t create join. Joining tables from different sources requires SPICE, which this dataset isn’t permitted to use. To continue, you’ll need to remove the join.)

---

<div class="post-metadata">

**Author:** ![hoyeon](https://avatars.discourse-cdn.com/v4/letter/h/dfb087/32.png) [@hoyeon](https://community.amazonquick.com/u/hoyeon)\
**Post date:** [October 12, 2024, 12:02am UTC](https://community.amazonquick.com/t/how-backend-works-when-joining-datasets/36062/8 "2024-10-12T00:02:36Z")

</div>

@Sanjeeb2022  
If the child dataset is SPICE, when is it refreshed? Should users schedule refresh?

When the child dataset is Direct Query - i.e, both parent datasets are Direct Query, does it automatically refresh when users open parent dataset?

> **[Creating a dataset using an existing dataset in Amazon QuickSight - Amazon...](https://docs.aws.amazon.com/quicksight/latest/user/create-a-dataset-existing-dataset.html)**
>
> Create a dataset in Amazon QuickSight using an existing dataset as a source for centralized data management, more customizable data, and predefined key metrics.

> This is the default query mode. If you choose this option, the data for this dataset automatically refreshes when you open an associated dataset, analysis, or dashboard.

---

<div class="post-metadata">

**Author:** ![Sanjeeb2022](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/sanjeeb2022/32/20947_2.png) [@Sanjeeb2022](https://community.amazonquick.com/u/Sanjeeb2022)\
**Post date:** [October 12, 2024, 4:02am UTC](https://community.amazonquick.com/t/how-backend-works-when-joining-datasets/36062/9 "2024-10-12T04:02:43Z")

</div>

Hi @hoyeon - When the child data set is in SPICE, yes you have to schedule it or refresh it first before using it in Parent data set. When the child data set is direct query, no refresh is require as the query will always connect to source database always.

If your final dataset is spice mode ( which is combination of child datasets). The best approach is to create a lambda function and refresh it through quicksight api.

Regards - Sanjeeb
