Hey! This content applies only to previous CARTO products

Please check if it's relevant to your use case. On October 2021 we released a new version of our platform.
You can learn more and read the latest documentation at docs.carto.com

Tutorials  /  Using Builder  /  General

How to preserve an analysis or query result in a dataset

Learn how map layers or SQL queries can be materialized to improve map performance.

Sometimes in CARTO we notice that maps take a lot of time to calculate a layer’s analysis or a custom SQL query result. To improve this, we can materialize our layer. That means that we store the layer’s result in a new CARTO dataset, instead of calculating it on the fly.

This new dataset can be loaded directly on our map, so the map doesn’t have to consume time automatically calculating that result on the fly when it is opened.

Materialize a Builder map analysis

Follow these steps to materialize a Builder map analysis:

  • Open a Builder map that contains an analysis.
  • Find the layer that contains your analysis. Click on the three dots located to the right of the layer’s name. A dropdown menu will appear. Select the Export data option to download the layer as a new dataset.

Export layer

We can use this approach to store one or more Builder map layer analyses in a new CARTO dataset.

Materialize Builder map SQL queries

Sometimes we want to use an analysis that isn’t already provided by Builder. For example, we might want to execute a custom spatial analysis using certain PostGIS functions. For these cases, Builder map layers provide an editable SQL panel that we can use to apply our query.

However our custom query’s result might take a long time to calculate, which can delay map rendering. In these cases it can be more efficient to create a new dataset from the query result and use that as a layer in our map.

Take these steps to create a dataset from a SQL query:

  • Open a CARTO dataset from your account’s Data dashboard, or by clicking on the blue link under your map layer’s title.
  • Set the Metadata/SQL toggle to SQL to open your dataset’s editable SQL panel.

open SQL panel

  • Replace the default query with your custom one and click Apply.

query

  • Click on the three dots located to the right of the dataset’s name. A dropdown menu will appear. Select the Create Dataset from query option to save the query results as a new dataset.

create dataset query

  • Add this new dataset to your map.