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

  • Home
  • SEARCH
  • 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 7685907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:21:26+00:00 2026-05-31T19:21:26+00:00

I am using Nhibernate in a project, and I am trying to run a

  • 0

I am using Nhibernate in a project, and I am trying to run a simple query to validate user logOn. It is working properly but very slow, and if i remove SingleOrDefault() it gets very very fast.

So my question is: Why .SingleOrDefault makes the following code very slow, and can I replace it by something to make it faster?

var user = Session.QueryOver<Customer>()
                    .Where(c => c.Username == username)
                    .SingleOrDefault();

Thank you

Edit:

This might be a little too much, but I am not quite sure how to filter it. The whole output from nhibernate during the SingleOrDefault step is :

2012-03-07 16:24:09,808 DEBUG NHibernate.Loader.Criteria.CriteriaQueryTranslator - put criteria=Username = Koste alias=this0_
2012-03-07 16:24:09,808 DEBUG NHibernate.Loader.Criteria.CriteriaQueryTranslator - returning alias=this_ for criteria=Username = Koste
2012-03-07 16:24:09,808 DEBUG NHibernate.AdoNet.AbstractBatcher - Opened new IDbCommand, open IDbCommands: 1
2012-03-07 16:24:09,808 DEBUG NHibernate.AdoNet.AbstractBatcher - Building an IDbCommand object for the SqlString: SELECT TOP (?) this_.CustomerID as CustomerID16_0_, this_.FirstName as FirstName16_0_, this_.LastName as LastName16_0_, this_.Username as Username16_0_, this_.Password as Password16_0_, this_.PersonalInformation as Personal6_16_0_, this_.LastLogin as LastLogin16_0_, this_.IsApproved as IsApproved16_0_, this_.IsReceiveRightsBulletins as IsReceiv9_16_0_, this_.CompanyID as CompanyID16_0_, this_.CustomerTypeID as Custome11_16_0_ FROM Customers.Customer this_ WHERE this_.Username = ?
2012-03-07 16:24:09,808 DEBUG NHibernate.Engine.QueryParameters - BindParameters(Positional0:NHibernate.Type.StringType) Koste -> [1]
2012-03-07 16:24:09,808 DEBUG NHibernate.Type.StringType - binding 'Koste' to parameter: 1
2012-03-07 16:24:09,808 INFO NHibernate.Loader.Loader - SELECT TOP (@p0) this_.CustomerID as CustomerID16_0_, this_.FirstName as FirstName16_0_, this_.LastName as LastName16_0_, this_.Username as Username16_0_, this_.Password as Password16_0_, this_.PersonalInformation as Personal6_16_0_, this_.LastLogin as LastLogin16_0_, this_.IsApproved as IsApproved16_0_, this_.IsReceiveRightsBulletins as IsReceiv9_16_0_, this_.CompanyID as CompanyID16_0_, this_.CustomerTypeID as Custome11_16_0_ FROM Customers.Customer this_ WHERE this_.Username = @p1
2012-03-07 16:24:09,808 DEBUG NHibernate.SQL - SELECT TOP (@p0) this_.CustomerID as CustomerID16_0_, this_.FirstName as FirstName16_0_, this_.LastName as LastName16_0_, this_.Username as Username16_0_, this_.Password as Password16_0_, this_.PersonalInformation as Personal6_16_0_, this_.LastLogin as LastLogin16_0_, this_.IsApproved as IsApproved16_0_, this_.IsReceiveRightsBulletins as IsReceiv9_16_0_, this_.CompanyID as CompanyID16_0_, this_.CustomerTypeID as Custome11_16_0_ FROM Customers.Customer this_ WHERE this_.Username = @p1;@p0 = 1 [Type: Int32 (0)], @p1 = 'Koste' [Type: String (250)]
2012-03-07 16:24:09,808 DEBUG NHibernate.Connection.DriverConnectionProvider - Obtaining IDbConnection from Driver
2012-03-07 16:24:09,840 DEBUG NHibernate.AdoNet.AbstractBatcher - ExecuteReader took 14 ms
2012-03-07 16:24:09,840 DEBUG NHibernate.AdoNet.AbstractBatcher - Opened IDataReader, open IDataReaders: 1
2012-03-07 16:24:09,840 DEBUG NHibernate.Loader.Loader - processing result set
2012-03-07 16:24:09,840 DEBUG NHibernate.Loader.Loader - result set row: 0
2012-03-07 16:24:09,840 DEBUG NHibernate.Type.Int32Type - returning '1' as column: CustomerID16_0_
2012-03-07 16:24:09,840 DEBUG NHibernate.Loader.Loader - result row: EntityKey[IPRBA.Core.Domain.Model.Customers.Customer#1]
2012-03-07 16:24:09,840 DEBUG NHibernate.Loader.Loader - Initializing object from DataReader: [IPRBA.Core.Domain.Model.Customers.Customer#1]
2012-03-07 16:24:09,840 DEBUG NHibernate.Persister.Entity.AbstractEntityPersister - Hydrating entity: [IPRBA.Core.Domain.Model.Customers.Customer#1]
2012-03-07 16:24:09,840 DEBUG NHibernate.Type.StringType - returning 'Koste' as column: FirstName16_0_
2012-03-07 16:24:09,840 DEBUG NHibernate.Type.StringType - returning 'Budinoski' as column: LastName16_0_
2012-03-07 16:24:09,840 DEBUG NHibernate.Type.StringType - returning 'Koste' as column: Username16_0_
2012-03-07 16:24:09,840 DEBUG NHibernate.Type.StringType - returning 'Koste123' as column: Password16_0_
2012-03-07 16:24:09,840 DEBUG NHibernate.Type.StringType - returning null as column: Personal6_16_0_
2012-03-07 16:24:09,840 DEBUG NHibernate.Type.DateTimeType - returning '1/1/2012 12:00:00 AM' as column: LastLogin16_0_
2012-03-07 16:24:09,840 DEBUG NHibernate.Type.BooleanType - returning 'True' as column: IsApproved16_0_
2012-03-07 16:24:09,840 DEBUG NHibernate.Type.BooleanType - returning 'False' as column: IsReceiv9_16_0_
2012-03-07 16:24:09,840 DEBUG NHibernate.Type.Int32Type - returning null as column: CompanyID16_0_
2012-03-07 16:24:09,840 DEBUG NHibernate.Type.Int32Type - returning '1' as column: Custome11_16_0_
2012-03-07 16:24:09,840 DEBUG NHibernate.Loader.Loader - done processing result set (1 rows)
2012-03-07 16:24:09,840 DEBUG NHibernate.Driver.NHybridDataReader - running NHybridDataReader.Dispose()
2012-03-07 16:24:09,840 DEBUG NHibernate.AdoNet.AbstractBatcher - Closed IDataReader, open IDataReaders :0
2012-03-07 16:24:09,840 DEBUG NHibernate.AdoNet.AbstractBatcher - DataReader was closed after 15 ms
2012-03-07 16:24:09,840 DEBUG NHibernate.AdoNet.AbstractBatcher - Closed IDbCommand, open IDbCommands: 0
2012-03-07 16:24:09,840 DEBUG NHibernate.AdoNet.ConnectionManager - aggressively releasing database connection
2012-03-07 16:24:09,840 DEBUG NHibernate.Connection.ConnectionProvider - Closing connection
2012-03-07 16:24:09,841 DEBUG NHibernate.Loader.Loader - total objects hydrated: 1
2012-03-07 16:24:09,841 DEBUG NHibernate.Engine.TwoPhaseLoad - resolving associations for [IPRBA.Core.Domain.Model.Customers.Customer#1]
2012-03-07 16:24:09,841 DEBUG NHibernate.Engine.Loading.LoadContexts - creating collection wrapper:[IPRBA.Core.Domain.Model.Customers.Customer.CustomerBookRights#1]
2012-03-07 16:24:09,841 DEBUG NHibernate.Engine.Loading.LoadContexts - creating collection wrapper:[IPRBA.Core.Domain.Model.Customers.Customer.CustomerContactInfos#1]
2012-03-07 16:24:09,841 DEBUG NHibernate.Engine.Loading.LoadContexts - creating collection wrapper:[IPRBA.Core.Domain.Model.Customers.Customer.CustomerMembershipTypes#1]
2012-03-07 16:24:09,841 DEBUG NHibernate.Engine.Loading.LoadContexts - creating collection wrapper:[IPRBA.Core.Domain.Model.Customers.Customer.CustomerSubscriptionTypes#1]
2012-03-07 16:24:09,841 DEBUG NHibernate.Event.Default.DefaultLoadEventListener - loading entity: [IPRBA.Core.Domain.Model.Customers.CustomerType#1]
2012-03-07 16:24:09,841 DEBUG NHibernate.Event.Default.DefaultLoadEventListener - creating new proxy for entity
2012-03-07 16:24:09,841 DEBUG NHibernate.Engine.TwoPhaseLoad - done materializing entity [IPRBA.Core.Domain.Model.Customers.Customer#1]
2012-03-07 16:24:09,841 DEBUG NHibernate.Engine.StatefulPersistenceContext - initializing non-lazy collections
2012-03-07 16:24:09,841 DEBUG NHibernate.AdoNet.ConnectionManager - after autocommit
2012-03-07 16:24:09,841 DEBUG NHibernate.Impl.SessionImpl - transaction completion
2012-03-07 16:24:09,841 DEBUG NHibernate.AdoNet.ConnectionManager - aggressively releasing database connection
  • 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-31T19:21:27+00:00Added an answer on May 31, 2026 at 7:21 pm

    After @Phil pointed the obvious we found out that the problem was in the logging, unrelated with the information provided.

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

Sidebar

Related Questions

I am trying to develop a .NET Web Project using NHibernate and Spring.NET, but
I am using NHibernate for my project. i am quite a beginner at working
I've been trying to get NHibernate into development for a project I'm working on
I am using NHibernate in a project, and I am trying to add it
I'm trying to setup a sample project using NHibernate and Fluent NHibernate. I am
I'm trying out my very first project with Fluent NHibernate (any NHibernate flavor for
I'm currently working on an ASP.NET MVC project using NHibernate and I need to
I am trying to use fluent nhibernate in a MVC project... i am very
I have a simple spring3,hibernate 3 project.When am trying to build the project using
We're building a project using NHibernate and Castle with the Validators project. I'm trying

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.