Re: Cache Issues

From: Fernando Chilvarguer (fernando_at_nospamimpex.com)
Date: 11/03/04


Date: Wed, 03 Nov 2004 03:32:25 GMT

Hi Steve,
Thank again for being such a great helper.

Here's the follow-up to your sugestion:

I ended up putting trace stuff everywhere and found the offending statement:

I was opening a connection to the database independent of getting the data
from the cache or from the DB.

I fixed that and now a connection is open ONLY when the data needs to be
loaded from the DB and not from the cache.

Of course, that created another question in my mind:

Why would opening a DB connection be fast sometimes and slow other times?
Shouldn't the time to open a DB connection be consistent? What am I missing?

The statement is:

SqlConnection myConnection;
string sConnString = "SERVER=" +
ConfigurationSettings.AppSettings["sServer"] .....
myConnection= new SqlConnection(sConnString);
try
{
myConnection.Open();
}

Sometimes is takes 0.002 seconds, sometimes it takes over 2 seconds.

Any ideas?

Thanks,
Fernando

"Steven Cheng[MSFT]" <v-schang@online.microsoft.com> wrote in message
news:u58Kly1uEHA.2916@cpmsftngxa10.phx.gbl...
> Hi Fernando,
>
> Thanks a lot for your detailed response and the code snippet. I've got the
> things you've done. From the code , you're writing trace everytime when
> you
> finished retrieving data from the cache....
>
> Currently I think you can try the following things:
> 1. Since the loading time we care about is during the following sentense:
>
> object cacheItem = context.Cache[cacheItemKey];
>
> that's the code which retrieve datas from the ASP.NET's cache collection.
> So I suggest you put some code to write out the current dateTime
> string(via
> System.DateTime.Now) into trace before and after that line of code so as
> to
> see whether the period of time is about the same. Such as :
>
> if(Cache[key] != null)
> {
> Trace.Write(current time...)
> object cacheItem = context.Cache[cacheItemKey];
> Trace.Write(current time..)
>
> }
>
> 2. Also, you may add some further tracing code in where it may be in the
> execute path at runtime when we retrieve data from trace. Thus, we can
> check whether they're always going through the same execute path when we
> got different period of time(it load data from cache).
>
> Also, if you have anyother ideas, please feel free to let me know. Thanks.
>
> Regards,
>
> Steven Cheng
> Microsoft Online Support
>
> Get Secure! www.microsoft.com/security
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
>
>



Relevant Pages

  • Re: Repost - Unable to authenticate a VPN
    ... a network trace of the machine attempting to make the VPN connection using ... the connection manager client.. ... On the client from a command prompt ... >> Microsoft Small Business Server Support ...
    (microsoft.public.windows.server.sbs)
  • Re: Server Does Not Exist or Access Denied error
    ... Server service pack installed and the one that I cannot connect to from my ... the connection is opened with no problem. ... > service packs are installed on each of the remote servers as I am not sure ... >> When I click Test Connection button, the trace indicates a successful ...
    (microsoft.public.sqlserver.connect)
  • RE: Connection Reset Error with SQLState() = 08S01
    ... This sounds like what would be called a general network error (GNE) in the non-JDBC world. ... Most GNEs can be traced down to a piece of hardware inappropriately resetting a connection. ... Here's the full stack trace. ...
    (microsoft.public.sqlserver.jdbcdriver)
  • Re: Repost - Unable to authenticate a VPN
    ... Thanks I did get the trace.. ... Microsoft Small Business Server Support ... >> the connection manager client.. ...
    (microsoft.public.windows.server.sbs)
  • Re: Cant connect to Oracle 9i when connected to DB2
    ... > (without retrieving data from either, ... I get a core dump when I try to open the Oracle ... > connection. ...
    (perl.dbi.users)