Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3671234
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T02:27:44+00:00 2026-05-19T02:27:44+00:00

my user’s table in the database is becoming increasingly larger (in terms of columns

  • 0

my user’s table in the database is becoming increasingly larger (in terms of columns not rows) and as a consequence is slowing down various areas of my site. This is because it tries to grab every column from the user’s table everytime it does a join against it.

I figured i would keep all the common fields in the user’s table and then put the additional fields in seperate tables. For example, say i have the following tables in my database:

Users:

- UserID (PK, Identity)
- UserName
- Password
...

UsersActivity:

- UserID (PK, FK)
- LastActivityDate
- LastLoginDate
...

UsersPreferences:

- UserID (PK, FK)
- HtmlEmail
- HideEmail
...

With the following entities:

public class User {
    public virtual int UserID { get; set; }
    public virtual string UserName { get; set; }
    public virtual string Password { get; set; }
    public virtual UserActivity Activity { get; set; }
    public virtual UserPreferences Preferences { get; set; }
}

public class UserActivity {
    public virtual User User { get; set; }
    public virtual DateTime LastActivityDate { get; set; }
    public virtual DateTime LastLoginDate { get; set; }
}

public class UserPreferences {
    public virtual User User { get; set; }
    public virtual bool HtmlEmail { get; set; }
    public virtual bool HideEmail { get; set; }
}

I was just wondering what is the best way to map this for optimum performance? I figured i could do a one-to-one mapping on the Activity and Performance properties in the User entity. However as far as i understand one-to-one mapping doesn’t support lazy loading and this approach would end up being slower.

I also looked into component mapping and wasn’t too sure whether i could map this into a seperate table (please correct me if it would be better to keep it in the same table) and whether components supported lazy loading.

Before i go about doing some heavy refactoring of my application i thought i would get the opinion of someone who might have done this. Really appreciate the help.

Thanks

Edit: I found that you could lazy load a one-to-one relationship as long as it is required/constrained. Which it is my case. Therefore i went ahead and carried out the instructions in the following article:

http://brunoreis.com/tech/fluent-nhibernate-hasone-how-implement-one-to-one-relationship/

The trouble now is that i get the error:

NHibernate.Id.IdentifierGenerationException: NHibernate.Id.IdentifierGenerationException: null id generated for: UserActivity.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T02:27:44+00:00Added an answer on May 19, 2026 at 2:27 am

    In NHibernate 3.0 one-to-one relationship supports lazy loading.

    And I think that it is better to use Component with combination of Lazy property. Then you will be able to leave all properties in one table and not load them all at once.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

User selects a database and its table, and will browse the table in a
User interface for web applications in general contain various buttons for performing CRUD operations.
User table contains the following attributes (dateOfBirth, race, gender, ...). We would like to
user table ======== id(int) | name(varchar) ------------------------ 1 | user1 2 | some_other_user product
User inserts new records in the table in his browser with no postback (using
User control's strings are localized by various resx files for certain languages in a
I need to clean up various Word 'smart' characters in user input, including but
User: columns: id: type: integer(4) autoincrement: true primary: true username: type: string(255) Group: tableName:
user table user_id entry user_id points_a points_b SELECT user.*, (SUM(entry.points_a) + SUM(entry.points_b)) as points_total
USER = user PASS = pass QUERY = SELECT c1, c2, c3, c4, c5,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.