Forum Discussion

wc123's avatar
wc123
Helper I
4 months ago
Solved

Query Time Outs

I have a query that i am running in SSMS that takes about 3-4 Minutes to finish executing. I bring that same query into powerbi using a native query and it never finishes executing. What is going on ...
  • v-dineshya's avatar
    4 months ago

    Hi wc123 ,

    Thank you for reaching out to the Microsoft Community Forum.

     

    Hi krishnakanth240  and parry2k , Thank you for your prompt responses.

     

    Power BI has a less default Timeout, It does not run your query like SSMS. It often runs it to get schema, to preview data, to validate metadata, during refresh and during relationship discovery. If you use Value.NativeQuery, Power BI may wrap it with extra SQL, this can break indexes prevent parallel plans. It Loads everything into memory, applies data type conversions and Compresses the model.

     

    SSMS has No timeout by default. It streams results and minimal transformation

     

    Please try below things to fix the issue.

    1. Increase Power BI Timeout, In Power Query:

    Source = Sql.Database(
    "Server_name",
    "Database_name",
    [
    Query = "YOUR QUERY",
    CommandTimeout = #duration(0, 0, 30, 0)
    ]
    )

    Note: Above "30" indicates 30 minutes.

     

    2. Use Value.NativeQuery

    let
    Source = Sql.Database("Server", "DB"),
    Data = Value.NativeQuery(
    Source,
    "YOUR QUERY",
    null,
    [EnableFolding=false]
    )
    in
    Data

     

    3.Disable Power BI Preview Load, Power BI Desktop:

    File --> Options --> Data Load.

    Enable data preview to download in the background

    Note: This prevents double execution.

     

    Please refer below snap for connection time out for Power bi.

     

     

    Please refer below snap for connection time out for SSMS.

     

     

     

    I hope this information helps. Please do let us know if you have any further queries.

     

    Regards,

    Dinesh