Power Automate Performance Optimization: How I Reduced a Flow from 6 Hours to 16 Minutes

Introduction

In this articule, I’ll show a real example of Power Automate performance optimization, where I reduced a flow execution time from 6 hours to 16 minutes.

I had a Power Automate flow that was taking around 6 hours to complete.

The flow was designed to:

  • Retrive all students (around 7,000 records)
  • Call an API for each student to get their invoices
  • Validate each invoice in the database
  • Insert new invoices if they didn’t exist

At first, everything worked correctly… but the performance was extremely poor.

The Original Flow

The original logic was simple:

  1. Get all students for the database
  2. Loop through each student
  3. Call API to get invoices
  4. For each invoice:
    • Validate in SQL if it exist
    • insert if not

Tha main bottleneck was the per-item SQL validation and insertion:
Each invoice was validated and inserted one by one using SQL actions.

Detected Problems

After analyzing the flow, I identified several issues:

  1. Too many SQL calls for validation
  2. Too many SQL insert operations
  3. No concurrency control (everything ran sequentially)
  4. Too many nested loops
  5. No use of in-memory data

Optimization Strategy

Instead of processing everything one by one, I changed the approach:

  1. Reduce SQL validations
  2. Use bulk operations instead of individual inserts
  3. Enable concurrency control
  4. Remove unnecesary loops
  5. Store data in memory (arrays)

Implementation (Optimized Flow)

This approach significantly improved the Power Automate performance by reducing database calls and processing data in memory.

In the new version of the flow:

  1. Retrieve all students and store them in an array
  2. Retrieve invoices filtered by recent dates (last 60 days)
  3. Store existing invoices in memory instead of SQL
  4. Collect new invoices in an array
  5. Perform a single bulk insert at the end
Power  Automate flow after

Results

Power Automate Performance Improvment

This optimization reduced execution time fro 6 hours to 16 minutes by eliminating unnecessary SQL calls and using bulk operations.

The biggest improvment came from eliminating the per-item SQL validation and insert.

MetricBeforeAfter
Execution time6 hours16 minutes
Students processed7,0007,000
Before
After

Good Practices

From this optimization, these are key takeways:

  • Use bulks operations whenever possible
  • Avoid unnecessary loops
  • Enable concurrency control carefully
  • Filter data early (reduce data set size)
  • Use in-memory processing instead of repeated database calls

Conclusion

If your flow is taking too long:

  1. Identify the bottleneck
  2. Reduce external calls (especially SQL)
  3. Process data in memory
  4. Use bulk operations

Small changes in desing can lead to masssive performance improvements.

If you want to learn more about Power Automate fundamentals, you can check the official documentation

🔗 Official Documentation

Learn more about Power Automate and best practices directly from Microsoft.

Go to Microsoft Docs →

You can also check this related article where I explain how to fix common Parse JSON errors in Power Automate.

Dejar un comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *

Scroll al inicio