{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":["callout","faq","faq-item","partial"]},"type":"markdown"},"seo":{"title":"Migrate from legacy SQL metrics to datasets","description":"Transition SQL-based custom metrics to datasets to reduce database load, consolidate queries, and unlock more flexible reporting.","siteUrl":"https://help.databox.com","llmstxt":{"title":"Databox Knowledge Base","description":"Databox is a business analytics platform that consolidates data in one place, enabling real-time performance tracking and insights by mixing and matching data from various sources for a comprehensive view.","details":{"content":"This knowledge base covers everything from account setup and integrations to building Databoards, creating custom metrics, and using AI-powered features."},"sections":[{"title":"General","includeFiles":["docs/general/*.md","docs/general/visualization-types/*.md","docs/general/templates/*.md"],"excludeFiles":[]},{"title":"AI","includeFiles":["docs/ai/*.md"],"excludeFiles":[]},{"title":"Account Management","includeFiles":["docs/account-management/**/*.md"],"excludeFiles":[]},{"title":"Databoards","includeFiles":["docs/databoards/**/*.md"],"excludeFiles":[]},{"title":"Data Management","includeFiles":["docs/data-management/**/*.md"],"excludeFiles":[]},{"title":"Metrics","includeFiles":["docs/metrics/**/*.md"],"excludeFiles":[]},{"title":"Forecasts","includeFiles":["docs/forecasts/*.md"],"excludeFiles":[]},{"title":"Goals","includeFiles":["docs/goals/*.md"],"excludeFiles":[]},{"title":"Reports","includeFiles":["docs/reports/*.md"],"excludeFiles":[]},{"title":"Notifications","includeFiles":["docs/notifications/*.md"],"excludeFiles":[]},{"title":"Pricing and Billing","includeFiles":["docs/pricing-and-billing/*.md"],"excludeFiles":[]},{"title":"Mobile","includeFiles":["docs/mobile/*.md"],"excludeFiles":[]},{"title":"Support","includeFiles":["docs/support/*.md"],"excludeFiles":[]},{"title":"Integrations","includeFiles":["docs/integrations/**/*.md"],"excludeFiles":[]}],"hide":false,"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"migrate-from-legacy-sql-metrics-to-datasets","__idx":0},"children":["Migrate from legacy SQL metrics to datasets"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"why-migrate-from-legacy-sql-metrics","__idx":1},"children":["Why migrate from legacy SQL metrics"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Legacy SQL metric builders are being deprecated, along with all custom metrics created using them for the following integrations:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Amazon Redshift"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Google BigQuery"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Microsoft Azure SQL"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Microsoft SQL Server"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["MySQL"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["PostgreSQL"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Snowflake"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Going forward, SQL metrics will be created using ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/understanding-datasets"},"children":["datasets"]},", which provide a more scalable and flexible way to work with your SQL data."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["With legacy SQL metrics, each metric runs its own query on every sync. If you have 200 metrics, that means 200 separate queries hitting your database every time data refreshes. This increases database load, slows down syncs, and makes ongoing maintenance more complex."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["With datasets, syncs are tied to datasets instead of individual metrics. One dataset query can power dozens or even hundreds of metrics. This significantly reduces database load and simplifies long-term management."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["By migrating to datasets, you can:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Store up to 20x more data"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Reuse the same dataset across multiple metrics"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Analyze data across multiple dimensions"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Apply filters and drill-downs directly in visualizations"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Create custom calculated columns"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Merge datasets from multiple data sources"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Export raw data when needed"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Use AI-powered insights with Genie and ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/query-and-analyze-your-data-using-ai-tools-and-databox-mcp"},"children":["Databox MCP"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Improve refresh performance and maintainability"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"Callout","attributes":{"type":"note"},"children":["In-app migration tools will be available soon to help identify legacy data sources and replace legacy SQL metrics. You may still choose to migrate manually based on your timeline or requirements, but the tooling will provide a more streamlined and reliable migration experience once available."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"key-considerations-for-migration","__idx":2},"children":["Key considerations for migration"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"whats-changing","__idx":3},"children":["What's changing"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Previously, each metric had its own SQL query that ran independently on every sync. Now, SQL queries are defined at the Dataset level, creating a data preparation step between your database and your metrics."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["One dataset query powers multiple metrics, and a single sync refreshes all metrics built on that dataset. Dimension filtering now happens at the metric level instead of in SQL WHERE clauses."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"what-stays-the-same","__idx":4},"children":["What stays the same"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Your existing database connection, account content, and historical data remain unchanged. The key difference is consolidating many per-metric queries into fewer, broader dataset queries."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"manual-migration-steps","__idx":5},"children":["Manual migration steps"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The biggest benefit of datasets comes from consolidating queries."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Instead of migrating each metric 1:1, look for patterns where multiple metrics query the same table with different filters."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"step-1-identify-legacy-sql-metrics","__idx":6},"children":["Step 1: Identify legacy SQL metrics"]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Go to ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://app.databox.com/metrics/custom-metrics"},"children":["Metrics > Custom Metrics"]},"."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Filter by your SQL data source (PostgreSQL, MySQL, Google BigQuery, etc.)."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Look for metrics marked with a ⚠️ warning icon."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Open each metric and ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["copy the SQL query"]}," for reference."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"step-2-identify-consolidation-patterns","__idx":7},"children":["Step 2: Identify consolidation patterns"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Look for metrics that:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Query the same table or set of tables"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Use the same or very similar JOIN structure"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Share the same base dataset but differ in filters, date granularity, aggregations, or calculated logic"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Common patterns include:"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"class":"table-header-col","className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Pattern"},"children":["Pattern"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Example"},"children":["Example"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Consolidation approach"},"children":["Consolidation approach"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Same query, different filter values"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["WHERE location_id = 101"]}," vs ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["WHERE location_id = 102"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Remove the hardcoded filter. Include ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["location_id"]}," in ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["SELECT"]},". Apply filtering at the metric level."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Separate queries for different aggregations"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["One metric uses ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["SUM(revenue)"]},", another uses ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["COUNT(order_id)"]}," from the same table"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Include all required measures in the same dataset query. Create separate metrics using different value columns or aggregations."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Separate queries for calculated variations"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["One metric calculates ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["SUM(revenue)"]},", another calculates ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["SUM(revenue) - SUM(cost)"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Return base columns (such as ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["revenue"]}," and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["cost"]},") in the dataset. Create calculated metrics or ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/add-a-calculated-column-to-a-dataset"},"children":["calculated columns"]}," instead of separate SQL queries."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Separate queries for different date grains"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["One query groups by ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["DATE(order_date)"]},", another by ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["DATE_TRUNC('month', order_date)"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Return data at the lowest useful grain (for example daily). Handle aggregation at the metric or visualization level."]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"step-3-create-consolidated-datasets","__idx":8},"children":["Step 3: Create consolidated datasets"]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Go to ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://app.databox.com/data-manager/datasets"},"children":["Data Manager > Datasets"]},"."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Click ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["+ New Dataset"]},"."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Select your SQL data source and click ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Continue"]},"."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Select ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Write SQL"]},"."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Enter your consolidated SQL query."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Click ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Preview data"]},"to confirm the structure and formatting look correct and the data appears as expected."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Click ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Continue"]},"."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Select update frequency and click ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Finish"]},"."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"step-4-recreate-metrics-from-the-datasets","__idx":9},"children":["Step 4: Recreate metrics from the datasets"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["For each legacy metric:"]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Open the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/view-a-dataset"},"children":["dataset view"]},"."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Click ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["+ Create new metric"]}," on the right-hand panel."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Select the appropriate ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["measure"]},", ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["date"]},",and ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["dimension"]}," columns."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Reapply any logic that previously lived in the SQL query, such as:",{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Adding filters that were previously in the WHERE clause"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Choosing the correct aggregation"]}]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Click ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Preview data"]}," and compare the new metric with the legacy metric to ensure the numbers align."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Click ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Save"]},"."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Replace the old metric wherever it's used across your content to ensure everything continues working with the new dataset-based metric."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"consolidation-example","__idx":10},"children":["Consolidation example"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"before-separate-queries-per-location","__idx":11},"children":["Before: Separate queries per location"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"sql","header":{"controls":{"copy":{}}},"source":"SELECT order_date::DATE AS \"Date\", SUM(total_amount) AS \"Revenue\"  \nFROM orders  \nWHERE location_id = 101  \nGROUP BY order_date::DATE  \nORDER BY \"Date\" DESC;\n","lang":"sql"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Same structure repeated for each location."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"after-one-dataset-query","__idx":12},"children":["After: One dataset query"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"sql","header":{"controls":{"copy":{}}},"source":"SELECT  \n    o.order_date::DATE AS \"Date\",  \n    l.location_id,  \n    l.location_name,  \n    SUM(o.total_amount) AS \"Revenue\"  \nFROM orders o  \nJOIN locations l ON o.location_id = l.location_id  \nGROUP BY o.order_date::DATE, l.location_id, l.location_name  \nORDER BY \"Date\" DESC;\n","lang":"sql"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Now you can filter by ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["location_id"]}," or ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["location_name"]}," at the metric level."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Result: One query replaces many. New locations appear automatically without modifying SQL queries."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"best-practices","__idx":13},"children":["Best practices"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["When creating consolidated datasets, focus on flexibility, clarity, and long-term maintainability."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"structure-your-query-for-flexibility","__idx":14},"children":["Structure your query for flexibility"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Include all columns that may be used for filtering, grouping, comparison, or future reporting in the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["SELECT"]}," statement."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Instead of hardcoding values in a ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["WHERE"]}," clause or excluding supporting fields, return those columns in your dataset so they become reusable dimensions. This makes the dataset more flexible and reduces the need to modify the SQL query later."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Keep datasets focused"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Avoid combining many unrelated tables into one large query. Overly broad datasets are harder to maintain and can slow down performance."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Instead, group related metrics into focused datasets, such as:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Sales and transactions"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Budget and goals"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Customer activity"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Employee performance"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"avoid-unnecessary-top-or-limit-clauses","__idx":15},"children":["Avoid unnecessary TOP or LIMIT clauses"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Legacy metrics often included ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["TOP"]}," or ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["LIMIT"]}," clauses as safeguards."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Datasets support significantly larger volumes of data, so artificial limits are usually unnecessary. Remove them unless they are required for performance or business logic."]},{"$$mdtype":"Tag","name":"Faq","attributes":{},"children":[{"$$mdtype":"Tag","name":"FaqItem","attributes":{"question":"Do I have to migrate everything at once?"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["No. You can migrate metrics at your own pace before the deprecation takes effect."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Group related metrics and migrate them together as a consolidated dataset. This makes it easier to validate results and ensure everything works correctly before moving on to the next group."]}]},{"$$mdtype":"Tag","name":"FaqItem","attributes":{"question":"Should I consolidate metrics that use different databases?"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["No. Each dataset connects to a single data source. Metrics that pull from different databases must be created as separate datasets."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["If you need to analyze data across multiple sources, you can ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/merge-datasets"},"children":["merge datasets"]}," after they are created."]}]},{"$$mdtype":"Tag","name":"FaqItem","attributes":{"question":"What if my consolidated dataset returns too much data?"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Datasets support a 20x larger data size limit compared to legacy SQL metrics. In most cases, removing a WHERE clause filter and adding the column as a dimension will still fit within the limit."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["If you reach the size limit, you can:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Add a date range filter in your query (for example, limit data to the last two years)"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Split the query into multiple focused datasets instead of one broad dataset"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Reduce granularity where appropriate, such as aggregating older data weekly instead of daily"]}]}]},{"$$mdtype":"Tag","name":"FaqItem","attributes":{"question":"What if my queries are too different to consolidate?"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Not all metrics should be combined into a single dataset. If metrics rely on different tables or fundamentally different JOIN structures, keep them as separate datasets."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Even partial consolidation delivers significant benefits. For example, reducing 100 individual queries to 10 dataset queries dramatically lowers database load and simplifies long-term maintenance."]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[" "]},{"$$mdtype":"Tag","name":"Cards","attributes":{"columns":4,"cardMinWidth":160},"children":[{"$$mdtype":"Tag","name":"FooterCard","attributes":{"title":"Ask Genie","icon":"genie","to":"https://app.databox.com/genie","variant":"elevated"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Get instant answers or help with your data using the in-app AI assistant."]}]},{"$$mdtype":"Tag","name":"FooterCard","attributes":{"title":"Talk to an expert","icon":"assistance","to":"https://meetings.hubspot.com/databox-meeting/account-management","variant":"elevated"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["For customers: Get help with your setup, strategy, or making the most of Databox."]}]},{"$$mdtype":"Tag","name":"FooterCard","attributes":{"title":"Book a demo","icon":"eye-open","to":"https://meetings.hubspot.com/databox-meeting/ref-knowledge-base","variant":"elevated"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["New to Databox? See how it works and get guidance on getting started."]}]},{"$$mdtype":"Tag","name":"FooterCard","attributes":{"title":"Send an email","icon":"help","to":"mailto:help@databox.com","variant":"elevated"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Reach out to support for help with your account, data, or technical issues."]}]}]}]},"headings":[{"value":"Migrate from legacy SQL metrics to datasets","id":"migrate-from-legacy-sql-metrics-to-datasets","depth":1},{"value":"Why migrate from legacy SQL metrics","id":"why-migrate-from-legacy-sql-metrics","depth":2},{"value":"Key considerations for migration","id":"key-considerations-for-migration","depth":2},{"value":"What's changing","id":"whats-changing","depth":3},{"value":"What stays the same","id":"what-stays-the-same","depth":3},{"value":"Manual migration steps","id":"manual-migration-steps","depth":2},{"value":"Step 1: Identify legacy SQL metrics","id":"step-1-identify-legacy-sql-metrics","depth":3},{"value":"Step 2: Identify consolidation patterns","id":"step-2-identify-consolidation-patterns","depth":3},{"value":"Step 3: Create consolidated datasets","id":"step-3-create-consolidated-datasets","depth":3},{"value":"Step 4: Recreate metrics from the datasets","id":"step-4-recreate-metrics-from-the-datasets","depth":3},{"value":"Consolidation example","id":"consolidation-example","depth":2},{"value":"Before: Separate queries per location","id":"before-separate-queries-per-location","depth":3},{"value":"After: One dataset query","id":"after-one-dataset-query","depth":3},{"value":"Best practices","id":"best-practices","depth":2},{"value":"Structure your query for flexibility","id":"structure-your-query-for-flexibility","depth":3},{"value":"Avoid unnecessary TOP or LIMIT clauses","id":"avoid-unnecessary-top-or-limit-clauses","depth":3}],"frontmatter":{"slug":"migrate-from-legacy-sql-metrics-to-datasets","seo":{"title":"Migrate from legacy SQL metrics to datasets","description":"Transition SQL-based custom metrics to datasets to reduce database load, consolidate queries, and unlock more flexible reporting."},"keywords":{"includes":["legacy SQL metrics deprecated","migrate SQL metrics to datasets","SQL metric builder deprecation","SQL custom metrics warning","consolidate SQL queries","dataset vs SQL metric","SQL dataset migration guide","reduce database load Databox","PostgreSQL dataset migration","MySQL dataset migration","BigQuery dataset migration","Snowflake dataset migration","WHERE clause to dimension filter","custom metric not working deprecated"]}},"lastModified":"2026-04-14T19:12:40.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/migrate-from-legacy-sql-metrics-to-datasets","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}