-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 
Author Message
 Post subject: What are the basic steps to improve the performance of NHib?
PostPosted: Wed Oct 05, 2005 12:18 pm 
Beginner
Beginner

Joined: Tue Aug 23, 2005 8:15 am
Posts: 45
I'm programming a Web-site and use NHibernate, ASP.NET and MS SQL Server 2000.
Some pages are ready but I'm worring about the performance.

The pages doesn't contain any hard queries.
They just retrieve object and their properties (single properties - links to other object and collections of objects) via NHibernate.

All collections (sets and bags (for sort)) are lazy (have lazy="true")
and not inverse (!!!) (inverse="false")
and biderctional (have link on child side)

In class hierarchies I use string type for disriminator.
(May be it is better to use numeric?)

I created SQL Server 2000 database from the SQL script, generated
by NHibernate (Configuration.GenerateSchemaCreationScript)
.

As I correct understand this script contains only indexes for primary and foreign keys and I should create all other indexes (Am I right?).

Tha main question is: what steps should I follow to improve the perfomance of the application.
Some pages execute 10-12 sec.
Sometimes the memory used by aspnet_wp.exe grows up to 100 Mb.


I can:
create indexes for discriminator fields and fields, which
are used in order by and other queries (I can see all SQL queries in NHibernate log)

What do you think is it a good way to start with?
Are other settings in NHibernate to improve them?

Best regards,
Sergey


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 05, 2005 12:36 pm 
Contributor
Contributor

Joined: Sat Sep 24, 2005 11:25 am
Posts: 198
Zero, profile the application and find the hot spots.
First, get a DBA to look at the databases.
Second, investigate caching.

It's very possible that you're doing things like:

int numOfPosts = blog.Posts.Count;

Which would load all the posts collection to memory just to get its count.

The answer for performance questions is always: Measure & Find Out.


Top
 Profile  
 
 Post subject: Re
PostPosted: Wed Oct 05, 2005 1:04 pm 
Beginner
Beginner

Joined: Tue Aug 23, 2005 8:15 am
Posts: 45
Thank you!
I look at nhibernate log.
At queries but didn't find any bottlenecks.

See a lot of queries with 3-6 left outer join.

---
about "int numOfPosts = blog.Posts.Count;"

I often iterate through collection attributes
(foreach) but never calculate count.

all collections are lazy.

A'm intersted in to know something about standard
bottlenecks of NHibernate configuration.

For example about using of sorted colections
or something else.

Do you know anything about "standart strategy" of creating
indexes in relation DB by xml-mapping files.

Something like: when I see a bas with order-by field A
so I should create an clustered index on A.



Ayende Rahien wrote:
Zero, profile the application and find the hot spots.
First, get a DBA to look at the databases.
Second, investigate caching.

It's very possible that you're doing things like:

int numOfPosts = blog.Posts.Count;

Which would load all the posts collection to memory just to get its count.

The answer for performance questions is always: Measure & Find Out.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 05, 2005 1:06 pm 
Newbie

Joined: Thu Sep 08, 2005 12:15 pm
Posts: 17
I had the same problem and I found that using left join fetch in my queries for the many-to-one or one-to-one relations improved a lot my app's performance. Using caching is also a most.

regards
Simon


Top
 Profile  
 
 Post subject: Thanks. Try fetch joins in my queries
PostPosted: Wed Oct 05, 2005 3:48 pm 
Beginner
Beginner

Joined: Tue Aug 23, 2005 8:15 am
Posts: 45
Does fetch join mean initializing collection attributes in one query?

what do you mean by caching?
Where can I read something about caching?

SimonH wrote:
I had the same problem and I found that using left join fetch in my queries for the many-to-one or one-to-one relations improved a lot my app's performance. Using caching is also a most.

regards
Simon


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 05, 2005 4:22 pm 
Newbie

Joined: Thu Sep 08, 2005 12:15 pm
Posts: 17
Quote:
Does fetch join mean initializing collection attributes in one query?


Yes

Quote:
Where can I read something about caching?


http://wiki.nhibernate.org/display/NH/Enabling+Second+Level+Cache

If you dont know what cache mean

http://en.wikipedia.org/wiki/Cache


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.