Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
9 years ago
Solved

Power BI data refresh locking all other users out of database

Dear all,   We are having a problem appear last week when refreshing against a SQL server though we haven't changed anything.   "Microsoft SQL: Execution Timeout Expired. The timeout period elaps...
  • Anonymous's avatar
    Anonymous
    9 years ago

    Hi,

     

    I found a solution. I don't know if this is the actual solution, but we haven't had the problem again.

     

    If I am getting the data from a SQL server then I do so as SQL query, where you have the option to specify the query, and I put a WITH(NOLOCK) clause in the FROM section of the SQL query - an example query is below. This will stop your query locking down the table to other users.

     

    You don't have to worry about this with Oracle as they don't have the same problem around lock states as SQL server. However, I do this anytime I am using SQL Server DBs now. This will stop any query folding that may take place as PBI can't push its queries into SQL anymore. So as a result in my larger projects I am now pushing as much data transformation and analysis into the SQL queries. I have noticed that this performs much better than any queries written in Power Query, and to be fair there isn't anything that Power Query can do that you can't do in SQL - apart from when you are having to mashup different data sources, which obviously you can't do with a SQL qry. However, if things are coming out of the same database then you want to use SQL to avoid all the performance issues of Power Query. 

     

    Plus another bonus is that your processing is done on your sql server which means that you won't end up having queries timing out or running out of juice when they try and refresh on the server.

     

    Basically, I am finding PBI is great for bringing together different data sources and for providing sharable visualisations, but it is really bad as a data transformation and querying tool. I hope Microsoft improves the performane and also provides some more documentation about how the M engine works.

     

    Example qry below using WITH(NOLOCK).

     

    let
       qry =
       "SELECT
           *
        FROM 
     TABLEA WITH(NOLOCK)
        LEFT JOIN 
     TABLEB WITH(NOLOCK)
     ON TABLEA.X = TABLEB.Y",

        run_sql = Sql.Database(myserver, mydatabase, [Query=qry, CommandTimeout=#duration(0, 0, 30, 0)])
    in
        run_sql