Is it possible that we're over thinking this? Have you copied and pasted the select statement in a SQL client tool and checked the performance of the "raw" database connection? Just wondering if it may be something as simply as a missing object, either on the entity you're running Get() on, or on one of the child tables it's processing?
On Sep 18, 5:19 pm, sravan <[email protected]> wrote: > The session factory is already created before the first call to get. > > i looked at sql profiler and it takes same time to execute in both > cases(First as well as second). > > I have many lazy loaded properties in the entity i am trying to load, > but no eagerly loaded properties. > > Sravan > > On Sep 18, 4:23 am, Oskar Berggren <[email protected]> wrote: > > > > > As Tuna says, be sure to not open two sessions if you in the future > > create a use case where two or more objects are retrieved and edited > > together. > > > Nonetheless, ten seconds for getting one object, and even two seconds > > on subsequent calls is ridiculous. > > > The times you mention, are they executing time for your Get(), or for > > only the call to session.Get()? > > > Does the first call include the time to configure and build the > > session factory? If it does, this could explain the whole or part of > > the 8 second difference, unless your domain model is very small. > > > If your sql server is slow to respond on connection requests (slow > > server, network problem, etc.) some time difference could be explained > > by this, since on the second request the connection is already > > available thanks to connection pooling (unless you've turned that > > off). > > > Now, two seconds for a subsequent call also seems overly much. Does > > you object have a bunch of eagerly initialized collections or other > > relations? How many sql queries are executed? Is connection pooling > > working? If you do the same SQL query manually, how long does it take? > > Is the database indexed properly? Does the database engine use the > > index? > > > Committing the transaction when you have only fetched data seems > > unnecessary and unclean. > > > /Oskar > > > 2009/9/18 Tuna Toksoz <[email protected]>: > > > > What if you get two objects and save 2 times? > > > > Tuna Toksöz > > > Eternal sunshine of the open source mind. > > > >http://devlicio.us/blogs/tuna_toksoz > > >http://tunatoksoz.com > > >http://twitter.com/tehlike > > > > On Fri, Sep 18, 2009 at 1:39 AM, Sravan Kumar > > > <[email protected]> wrote: > > > >> I am following unit of work pattern. UI tier calls Business tier to get > > >> an > > >> entiy with ID. > > > >> Gettting an objec with ID is Unit Of work in this example. I Get an > > >> entity > > >> bind it to UI and then do some modifications and then calls > > > >> Save. Save is a another unit of work. > > > >> Thank you very much . > > >> Sravan > > > >> On Thu, Sep 17, 2009 at 6:33 PM, Tuna Toksoz <[email protected]> wrote: > > > >>> Opening a session in every operation is bad. You loose unit of work + > > >>> first level cache etc. > > >>> Don't do it. > > > >>> Tuna Toksöz > > >>> Eternal sunshine of the open source mind. > > > >>>http://devlicio.us/blogs/tuna_toksoz > > >>>http://tunatoksoz.com > > >>>http://twitter.com/tehlike > > > >>> On Thu, Sep 17, 2009 at 9:31 PM, sravan <[email protected]> > > >>> wrote: > > > >>>> I have a Get Method that takes the ID of the entity and gives the > > >>>> object with that ID. > > > >>>> In the Get Method I open a new session and calls Get on the session. > > > >>>> the first call to get takes 10 sec, but subsequent calls to get takes > > >>>> just 2 seconds. > > > >>>> I do not have second level caching enabled. > > > >>>> I ran the sql server profiler and it is taking the same time to > > >>>> execute the query in both the cases. > > > >>>> Not able to figure out why it is taking so long time for first call to > > >>>> get. > > > >>>> Any help is Greatly appreciated. > > > >>>> The second call is invoked on a different session. > > > >>>> public virtual T Get( long ID ) > > >>>> { > > > >>>> if ( null == Interceptor ) throw new TechnicalException > > >>>> ( "RepositoryBase::Get: ERROR: Interceptor must be set prior to use of > > >>>> this class." ); > > > >>>> T entity = null; > > >>>> using ( ISession session = > > >>>> NHibernateSessionFactorySingleton.GetSession( Interceptor ) ) > > >>>> { > > >>>> using ( ITransaction transaction = > > >>>> session.BeginTransaction( ) ) > > >>>> { > > > >>>> session.FlushMode = > > >>>> FlushMode.Never; > > > >>>> T entity = session.Get<T>( ID ); > > > >>>> transaction.Commit( ); > > >>>> } > > > >>>> } > > > >>>> return entity; > > >>>> } > > > >>>> Sravan- Hide quoted text - > > - Show quoted text - --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~----------~----~----~----~------~----~------~--~---
