• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

Azure function, slooooow.

Collapse
X
  •  
  • Filter
  • Time
  • Show
Clear All
new posts

    #11
    What if you run a logic app with sql connector instead of the function?

    Comment


      #12
      Move it all to AWS Lambda, M$ suck.

      Comment


        #13
        The only other thing I can think of is a none azure specific issue such as a bad execution plan OPTION(RECOMPILE) on the azure function call to the proc or corruption in the buffer.

        Edit: Are the database indexes and statistics fresh?

        https://docs.microsoft.com/en-us/sql...s-transact-sql

        Failing that try turning turing sql server on and off again if you can get a window to do that.
        Last edited by BlueSharp; 22 March 2018, 22:47.
        Make Mercia Great Again!

        Comment


          #14
          Originally posted by BlueSharp View Post
          The only other thing I can think of is a none azure specific issue such as a bad execution plan OPTION(RECOMPILE) on the azure function call to the proc or corruption in the buffer.

          Edit: Are the database indexes and statistics fresh?

          https://docs.microsoft.com/en-us/sql...s-transact-sql

          Failing that try turning turing sql server on and off again if you can get a window to do that.
          I think it's very likely to be something related to the statistics/dodgy plan.

          I think Mudskipper might be onto something with SET ARITHABORT ON. I've read a couple of answers on SO and people say it's sorted their problem out then others have pointed out that it may be a red herring and it's actually a dodgy plan.

          I did try setting SET ARITHABORT ON in the stored procedure but no difference. But from what I've read the actual connection from ado.net trumps the stored procedure settings. So I'm going to attempt to change the code in the Azure function to set this on for the connection. Working with live data so will make the change and allow it to run in the morning.

          I'm limited on time at the moment so going for the the low hanging fruit. But my feeling is it's actually not related to the function at all and as you have said it's db.

          Comment


            #15
            Originally posted by woohoo View Post
            I think it's very likely to be something related to the statistics/dodgy plan.

            I think Mudskipper might be onto something with SET ARITHABORT ON. I've read a couple of answers on SO and people say it's sorted their problem out then others have pointed out that it may be a red herring and it's actually a dodgy plan.

            I did try setting SET ARITHABORT ON in the stored procedure but no difference. But from what I've read the actual connection from ado.net trumps the stored procedure settings. So I'm going to attempt to change the code in the Azure function to set this on for the connection. Working with live data so will make the change and allow it to run in the morning.

            I'm limited on time at the moment so going for the the low hanging fruit. But my feeling is it's actually not related to the function at all and as you have said it's db.
            There's also the parameter sniffing stuff. I changed my SPs to assign the passed parameters to local variables and use them in the query. Can't be sure whether it made a difference - my comment said " -- This might help... "

            Comment


              #16
              Originally posted by mudskipper View Post
              There's also the parameter sniffing stuff. I changed my SPs to assign the passed parameters to local variables and use them in the query. Can't be sure whether it made a difference - my comment said " -- This might help... "
              hah yeah, I'm currently reading this about parameter sniffing...

              Slow in the Application, Fast in SSMS?

              Comment


                #17
                Originally posted by woohoo View Post

                I did try setting SET ARITHABORT ON in the stored procedure but no difference. But from what I've read the actual connection from ado.net trumps the stored procedure settings. So I'm going to attempt to change the code in the Azure function to set this on for the connection. Working with live data so will make the change and allow it to run in the morning.
                At the risk of stating the bleedin' obvious, you could try setting to OFF in the SP and see if it runs slow in SSMS - would at least indicate whether it's worth pursuing.

                https://docs.microsoft.com/en-us/sql...t-transact-sql

                Comment


                  #18
                  I’ve read the article before thanks.

                  Just as easy to change the azure function. I’m having a day off and will take a look at it Sunday.

                  Comment


                    #19
                    Just in case anyone is interested. The Azure function timing reduced itself from 6 mins to 17 seconds without changing anything.

                    I didn't get a chance to deploy the change to the Azure function to SET ARITHABORT ON for the login session but if it helps someone else here is the code I pinched and tested.

                    Code:
                                    
                    conn.StateChange += new StateChangeEventHandler(OnStateChange);
                    conn.Open();
                    Code:
                            
                    private static void OnStateChange(object sender, StateChangeEventArgs args)
                    {
                        if (args.OriginalState == ConnectionState.Closed
                            && args.CurrentState == ConnectionState.Open)
                        {
                            using (SqlCommand cmd = ((SqlConnection)sender).CreateCommand())
                            {
                                cmd.CommandType = CommandType.Text;
                                cmd.CommandText = "SET ARITHABORT OFF;";
                    
                                cmd.ExecuteNonQuery();
                            }
                        }
                    }

                    Comment


                      #20
                      Originally posted by woohoo View Post
                      The Azure function timing reduced itself from 6 mins to 17 seconds without changing anything.
                      Most unsatisfactory The black art of databases.

                      Comment

                      Working...
                      X