Why Is Dataflow Gen2 Slow (compared to PySpark notebooks)?
From the publisher’s feed, collected in the ZeroLabs newsroom.
A Guide for Microsoft Fabric Engineers. Understanding the architecture, benchmarking against PySpark, and knowing when to use whatIf you’ve worked with Microsoft Fabric’s Dataflow Gen2, you’ve probably had this moment: you kick off what looks like a simple transformation, and then… nothing. For 45 seconds. A minute. Sometimes longer. You start wondering if something went wrong, or if you made a terrible architectural choice.You didn’t. But there’s a lot going on beneath that spinning cursor, and understanding it will change how you design your Fabric pipelines entirely.This article covers three things:1. Why Dataflow Gen2 is slow (the root causes)2. Why it’s slower than PySpark Notebooks (the architectural tradeoff)3. What you can actually do about it (practical fixes and decision rules)Part 1: The Root Cause, It’s Spark All the Way DownThe single biggest reason Dataflow Gen2 feels slow, especially on small jobs, is that it runs on Apache Spark under the hood.Spark is a distributed processing engine built for massive datasets. It’s the same technology behind large-scale data lakes, petabyte-scale analytics, and enterprise ETL pipelines that process billions of rows. When you run a Dataflow Gen2, Fabric is essentially spinning up a Spark cluster, running your transformation, and tearing it back down.That spin-up alone adds 30 to 120 seconds of cold start latency, before a single row of your data is touched.This isn’t a bug. It’s the architecture. But it catches a lot of engineers off guard, especially those coming from Power Query or SQL backgrounds where small transformations execute in seconds.Part 2: The 8 Reasons Your Dataflow Gen2 Is Slow1. Spark Cold Start (The Big One)Every execution allocates compute from scratch. There’s no persistent, always-on cluster waiting for your query. The moment you hit Run:• A cluster is requested and allocated• The Spark environment is initialized• Only then does your data get processedFor a 10,000 rows dataset, you’re paying Spark startup tax on work that a SQL stored procedure would finish in milliseconds.2. No Always-On ComputeUnlike a dedicated SQL pool or a database server, Dataflow Gen2 doesn’t maintain a hot engine between runs. Every scheduled refresh, every manual trigger; cold start, every time.3. Built for Big Data, Not Small JobsDataflow Gen2 is optimized for large-scale transformations across millions of rows, parallel processing across distributed partitions, and complex multi-step transformations on structured or semi-structured data.If your use case is loading a 50KB lookup table or doing a three-column pivot on a few thousand rows, you’re using a freight train to deliver a pizza.4. Data Serialization and Movement OverheadReading from a source and writing to a Lakehouse or Warehouse isn’t as simple as it sounds. Spark internally shuffles data across partitions, converts formats (often to Parquet or Delta), and manages distributed write coordination. Each of these steps adds overhead that compounds with complexity.5. Complex Transformations Are Genuinely ExpensiveCertain operations carry a heavy Spark cost: joins (especially between large tables), aggregations and GROUP BY operations, window functions, and derived columns with complex conditional logic. Poor partitioning makes all of these worse, if Spark doesn’t partition your data well relative to your transformations, it spends more time shuffling than computing.6. Default Parallelism May Not Fit Your DataSpark’s auto-configuration is a best guess. It often results in too many small partitions (causing excessive overhead) or too few partitions (causing underutilized compute and serial bottlenecks). Neither extreme is fast.7. Debug Mode vs. Production RunsIf you’re testing in Debug mode, expect it to be noticeably slower than a production pipeline run. Debug mode is not representative of real-world performance; but many engineers benchmark from there and walk away with the wrong impression.8. Sink Operations Are a Hidden SlowdownWriting data out is often where time disappears. Auto-creating tables forces schema inference at runtime, small file writes create fragmented Delta tables, and schema mismatches trigger retries or conversions. This is one of the most overlooked performance killers in Dataflow Gen2.Part 3: Why Dataflow Gen2 Is Slower Than PySpark NotebooksDataflow Gen2 uses Power Query (M language) as its authoring interface. That M code gets translated into Spark jobs by the Fabric engine before execution:M Query → Fabric engine → Spark plan → ExecutionPySpark in a Notebook goes directly:Your code → Spark executionEvery translation layer adds overhead. The Fabric engine has to interpret your M transformations, generate a Spark execution plan, and optimize it, and that optimization isn’t always as good as what an experienced engineer would write manually.The 9 Specific GapsThe Design Intention Behind the GapThis isn’t a flaw in Dataflow Gen2. It’s a deliberate design tradeoff:You are trading performance and control for ease of use and accessibility. Dataflow Gen2 is, in a very real sense, the Power BI of data engineering; approachable, visual, and productive for the right workloads. PySpark is the full engine, exposed.The mistake isn’t using Dataflow Gen2. The mistake is using it for workloads that need what PySpark provides.Part 4: How to Make Dataflow Gen2 FasterEven within its constraints, there’s meaningful room to optimize.Match the Tool to the Workload FirstBefore tuning anything, ask honestly: should this even be a Dataflow Gen2?Push Work Back to the SourceUse query pushdown wherever possible. Select only the columns you need, filter rows before they hit Spark, and let the source system do the heavy filtering. The less data Spark has to ingest, the faster it runs.Reduce Transformation StepsEvery transformation step is a Spark stage. Combine steps where you can. Avoid redundant intermediate outputs. The shorter your transformation chain, the less total overhead accumulates.Optimize JoinsUse broadcast joins for small lookup tables; this avoids expensive data shuffles. Filter before joining, not after. Where you can pre-aggregate or pre-filter a dataset before a join, apply it.Control Partitioning IntentionallyDon’t leave partitioning entirely to Spark’s auto-config. Avoid designs that create thousands of tiny partitions. Aim for partition sizes in the 128MB–512MB range. Choose distribution keys that match your transformation patterns.Pre-Create Your Sink TablesOne of the easiest wins: don’t let Dataflow Gen2 auto-create tables in production. Pre-create your target tables with the correct schema. This eliminates runtime schema inference, table creation overhead, and potential type mismatch retries. After large loads, run OPTIMIZE on your Delta tables.Think in Batches, Not RowsIf you find yourself designing row-by-row logic; loops, conditional row updates, iterative patterns; stop. Rewrite it as a bulk transformation. Spark is built for set-based operations. Row-level iteration is catastrophically slow in a distributed engine.Fewer, Bigger PipelinesMany small Dataflows chained together multiply your cold start tax. Consolidate where it makes sense, fewer, well-optimized Dataflows will almost always outperform many lightweight ones strung together.Final thoughtsDataflow Gen2 isn’t slow, it’s appropriately sized for a different problem than many people use it for.It’s a distributed data transformation engine built for scalability, not speed on small tasks. It will always have startup overhead, because that overhead is the cost of elastically provisioning compute on demand. For the workloads it’s designed for millions of rows, complex multi-step transformations, scalable ETL, that tradeoff is completely justified.The engineers who struggle with it are usually the ones applying it to jobs that don’t need distributed compute. The ones who thrive are the ones who respect the tool’s nature and design accordingly.Follow for more practical content on Microsoft Fabric, Power BI, and modern data engineeringWhy Is Dataflow Gen2 Slow (compared to PySpark notebooks)? was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.