none
WCF data service very slow on first query RRS feed

  • Question

  • I have a WCF data service sitting on IIS hosted in Windows 2008 R2.

    The first time I run a query against the Service it is very slow 6~10 seconds or longer.

    If I post an update to the table it is also very slow the first time.

    It is slow from a Javascript inside an html file or from a Windows form application.

    Monday, August 31, 2015 8:03 PM

Answers

  • If the Web service went out of scope because it sat idle for sometime, then it has to be complied and put back into scope.

    Simply disconnecting the client causes the issue.

    I don't know what to tell you. If the Web service didn't go out of scope, then it shouldn't be a problem. You should use Fiddler and see if you can spot something.

    If are doing something with Linq and it's a query first, then the query has to be compiled.

    Should that really take 5~10 seconds or more?

    Yeah it can on first time usage, and that is why you do static complied Linq queries so that they stay in static memory and don't have to be compiled again, as long as the ASP.NET Worker Process WpW3.exe that is servicing the App Pool that is hosting the Web application doesn't get recycled.

    But on a first time usage regardless, the Linq query has to be compiled,  and you are going to take a hit on first time query. There are other factors too like if using an ORM like EF where the virtual model has to parsed for all objects every time on a connection open on the model, which can be circumvented by using compiled views.

    Monday, August 31, 2015 10:11 PM

All replies

  • The first time I run a query against the Service it is very slow 6~10 seconds or longer.

    If the Web service went out of scope because it sat idle for sometime, then it has to be complied and put back into scope.

    If I post an update to the table it is also very slow the first time.

    If are doing something with Linq and it's a query first, then the query has to be compiled.

    It is slow from a Javascript inside an html file or from a Windows form application.

    Either way, the same rules apply when hitting the service.

    Monday, August 31, 2015 9:14 PM
  • If the Web service went out of scope because it sat idle for sometime, then it has to be complied and put back into scope.

    Simply disconnecting the client causes the issue.

    If are doing something with Linq and it's a query first, then the query has to be compiled.

    Should that really take 5~10 seconds or more?

    Monday, August 31, 2015 9:18 PM
  • If the Web service went out of scope because it sat idle for sometime, then it has to be complied and put back into scope.

    Simply disconnecting the client causes the issue.

    I don't know what to tell you. If the Web service didn't go out of scope, then it shouldn't be a problem. You should use Fiddler and see if you can spot something.

    If are doing something with Linq and it's a query first, then the query has to be compiled.

    Should that really take 5~10 seconds or more?

    Yeah it can on first time usage, and that is why you do static complied Linq queries so that they stay in static memory and don't have to be compiled again, as long as the ASP.NET Worker Process WpW3.exe that is servicing the App Pool that is hosting the Web application doesn't get recycled.

    But on a first time usage regardless, the Linq query has to be compiled,  and you are going to take a hit on first time query. There are other factors too like if using an ORM like EF where the virtual model has to parsed for all objects every time on a connection open on the model, which can be circumvented by using compiled views.

    Monday, August 31, 2015 10:11 PM