🎉 75% of content is free forever — Unlock Premium from $10/mo →
CW
NEWSLIVESearch All Content
đŸ’ŧ Servicesâ„šī¸ Aboutâœ‰ī¸ ContactView Pricing Plansfrom $10

Synapse Serverless SQL: External Tables and Cost

Azure Data EngineeringSynapse Serverless⭐ Premium

Synapse serverless SQL lets you run T-SQL against files that already sit in ADLS Gen2, without provisioning a pool or copying data into a table first. That makes it the natural first tool for exploration, prototyping, and light transformations, and it also makes it a service whose cost you can accidentally multiply with a careless query.

After this lesson you will be able to:

  • Set up credentials, data sources, and file formats correctly.
  • Decide between external tables, views, and ad hoc OPENROWSET.
  • Structure files and statistics so the optimizer can help you.
  • Predict and control the per-terabyte-scanned charge.

Prerequisites

  • !T-SQL familiarity
  • !ADLS Gen2 containers and paths
  • !A Synapse workspace with a serverless SQL endpoint

What serverless really means here

There is no long-running compute allocation. Each query spins up execution resources, reads the files it needs, and returns results, and you are billed for the volume of data scanned. Nothing is loaded into a persistent store, so the lake stays the single source of truth and the SQL endpoint is a view over it.

That model has two consequences. First, file format matters enormously: reading Parquet lets the engine skip row groups and columns, while reading raw CSV forces it to parse every byte of every file. Second, query design becomes a cost control. A filter that prunes partitions reduces both runtime and the bill, which is a rare case where the fast query is also the cheap one.

Because the endpoint is stateless, it is also safe to share. Analysts can explore curated paths without needing write access anywhere, and engineers can promote a well-used query into an external table or view once its shape stabilizes.

Credentials, data sources, and formats

Access is granted through a database-scoped credential that typically carries the workspace managed identity, so no key or SAS token is stored in the script.

CREATE DATABASE SCOPED CREDENTIAL adls_identity
WITH IDENTITY = 'Managed Identity';

CREATE EXTERNAL DATA SOURCE lake_source
WITH (
    LOCATION = 'https://stadls001.dfs.core.windows.net',
    CREDENTIAL = adls_identity
);

CREATE EXTERNAL FILE FORMAT parquet_format
WITH (
    FORMAT_TYPE = PARQUET,
    DATA_COMPRESSION = 'org.apache.hadoop.io.compress.SnappyCodec'
);

CREATE EXTERNAL TABLE raw.Sales
WITH (
    LOCATION = 'raw/sales/',
    DATA_SOURCE = lake_source,
    FILE_FORMAT = parquet_format
)
AS
SELECT * FROM OPENROWSET(
    BULK 'raw/sales/dt=*/*.parquet',
    FORMAT = 'PARQUET'
) WITH (
    sale_id BIGINT,
    customer_id INT,
    order_date DATE,
    quantity INT,
    unit_price DECIMAL(18,2),
    total_amount DECIMAL(18,2)
) AS s;

Keeping the credential on a managed identity removes a whole category of maintenance: nothing expires, and access can be revoked through role assignments rather than by rotating a secret stored in a script.

External tables, views, or plain OPENROWSET

The three approaches differ in what they persist, and choosing the wrong one either hides information or creates duplication.

ConstructStoresBest forDownside
OPENROWSETNothing, defined inlineQuick ad hoc explorationSchema restated every query
External tableMetadata over filesRepeated access to a stable datasetRequires DDL changes if schema moves
ViewA reusable query definitionJoining curated paths for consumersNo statistics benefit unless created
Materialized external tableA new copied datasetRepeated heavy transformationsData duplication and refresh cost

A sensible progression is to prototype with OPENROWSET, formalize a stable path as an external table, and wrap it in a view once the shape is used by more than one person. Only create a physical copy when the transformation cost genuinely exceeds the cost of repeatedly scanning the source.

Building a small lake database pattern

Views and statistics turn a folder of files into something that behaves like a schema people can work against.

CREATE SCHEMA analytics;
GO

CREATE STATISTICS st_sales_order_date
ON raw.Sales (order_date) WITH FULLSCAN;

CREATE VIEW analytics.vw_DailySales
AS
SELECT
    order_date,
    COUNT_BIG(*) AS transactions,
    SUM(total_amount) AS revenue,
    SUM(total_amount) / NULLIF(COUNT_BIG(*), 0) AS avg_order_value
FROM raw.Sales
WHERE order_date IS NOT NULL
GROUP BY order_date;

CREATE VIEW analytics.vw_CustomerRevenue
AS
SELECT
    customer_id,
    MIN(order_date) AS first_order,
    MAX(order_date) AS last_order,
    SUM(total_amount) AS lifetime_revenue
FROM raw.Sales
GROUP BY customer_id;

Statistics give the optimizer cardinality estimates, which it uses to choose join order and broadcast decisions. Without them it defaults to guesses, and on a large join the difference between a good guess and a bad one is measured in minutes.

The per-terabyte model, and how to stay on the right side of it

The cost of a serverless query is roughly the volume of data scanned multiplied by the per-terabyte rate. Everything you do to reduce scanning reduces the bill proportionally, so the design rules follow directly.

Partition the data on a column that filters appear with, usually a date, and name folders so the engine can prune them without opening files. Use Parquet rather than CSV wherever possible, since column and row-group statistics let the engine skip data inside a file as well as whole files. Select only the columns you need instead of using a wildcard, because columnar storage makes that a genuine saving rather than a micro-optimization.

Schedule known heavy reports so they do not collide with exploratory sessions, and review the workspace's queried data volume weekly. A single unfiltered query over a large raw path can cost more than a day of a dedicated pool during quiet periods, which is the failure mode that surprises teams who assumed serverless would always be cheaper.

Limitations worth designing around

Serverless SQL is read-oriented. Stored procedures, most DML, and cross-database queries are not available, and there is no result set caching to rescue a repeatedly run dashboard. Performance depends heavily on file layout, because the service has no indexes to fall back on.

Use it as the query and preparation layer rather than as the serving layer for high-concurrency dashboards. Land curated outputs as Delta or as a dedicated pool table when a workload needs predictable performance, and keep serverless for the exploratory and transitional work where its flexibility is the point.

Who is allowed to read what

Because the endpoint reads files through a managed identity, permissions are decided at two layers: who can run queries against the SQL endpoint, and whether that identity can reach the underlying path. Both have to be correct, and the failure modes look different. Without endpoint access the user cannot connect at all; without storage access the query connects and then returns a file access error, which is easy to misread as a path mistake.

Grant table-level permissions for views and external tables so consumers never touch the raw container directly. The same principle applies to partitions that contain restricted data: keep those under separate paths with separate grants rather than relying on users to filter responsibly.

Row-level policies can be layered on top with predicates in views, which is simpler to audit than scattering filters across reports. Document which layers protect which dataset, because a control that exists only in one report gives a false sense of coverage across everything else built on the same source.

Common Mistakes

Querying raw CSV files with no partition filter

Fix: Convert hot paths to partitioned Parquet and always filter on the partition column first.

Restating a complex external definition in every ad hoc query

Fix: Promote stable paths to external tables and wrap them in views so consumers share one definition.

Assuming serverless is always cheaper than a pool

Fix: Track scanned terabytes weekly and compare against dedicated pool cost for the same workload.

Running a dashboard against serverless for high concurrency

Fix: Materialize curated results into a serving layer designed for repeated concurrent reads.

Best Practices

  • Authenticate with a managed identity instead of stored keys
  • Partition by the column your filters use and keep folder names predictable
  • Select explicit columns rather than reading every field
  • Create statistics after any significant data volume change
  • Use serverless to prepare, and a serving layer to publish

Questions interviewers ask about serverless

đŸŽ¯Interview Tip

Cost questions are common here. Be ready to explain that the charge follows data scanned, so a partition-pruned Parquet query over one day costs a tiny fraction of a full CSV scan, and to name the specific design choices that produce that difference.

Interview Questions

Q1: When would you use serverless instead of a dedicated SQL pool?

For ad hoc exploration, prototyping, and irregular workloads where paying per terabyte scanned beats paying for always-on capacity. Move to a dedicated pool when you need predictable performance, result caching, stored procedures, or high concurrency.

Q2: How do external tables work?

They store schema, data source, and file format metadata over files that remain in ADLS. Queries push computation down to storage, reading only the columns and partitions required, and no data is copied into the SQL pool.

Q3: How do you reduce serverless costs?

Partition data on commonly filtered columns, store it as Parquet so statistics enable skipping, select only needed columns, and add filters before any join. Each of those reduces bytes scanned, which is the unit you are billed on.

Q4: What are the main limitations?

No stored procedures, limited DML, no cross-database queries, no result set caching, and performance tied to file layout rather than indexes. That is why it excels at preparation and is the wrong choice as a high-concurrency serving tier.

Key Takeaways

  • Serverless bills by data scanned, so pruning is the cost control
  • Parquet plus partitioning gives the optimizer ways to skip data
  • Managed identity credentials remove secret rotation entirely
  • Promote OPENROWSET to external tables to views as usage stabilizes
  • Statistics materially improve join decisions even without indexes
  • Use serverless to prepare data and a serving layer to publish it
🔒

Premium Content

Synapse Serverless SQL: External Tables and Cost

You've previewed the first section. Unlock this full lesson and 900+ advanced tutorials with a Premium plan.

đŸŽ¯End-to-end Projects
đŸ’ŧInterview Prep
📜Certificates
🤝Community Access

Already a member? Log in

CW

ChatWhole Learn Editorial Team

Written by experienced data scientists, software engineers, and educators. All content is reviewed by industry professionals to ensure accuracy and relevance.

Last reviewed: 2026-10-12

—
☆☆☆☆☆
0 ratings

Rate & Feedback

Advertisement