0

In the NHiberante, I have this statement

 (from p in Session.Query<MyObject>() select p).Count(); 

is this equal to this ?

select count(*) from MyObject

assume object name is same as table name .

If the table data is huge, do we have a way to improve performance ?

thanks

1
  • If the table is really large, one way to improve performance would be to cache results or store a running total somewhere. Not much you can do to improve a rowcount as it is. Commented May 4, 2012 at 14:04

1 Answer 1

1

You can better use:

(from p in Session.Query<MyObject>() select p).LongCount();

SQLite query is:

select cast(count(*) as BIGINT) as col_0_0_ from MyObject myobject0_

You can create DBMS specific optimized queries with:

Session.CreateSQLQuery("sql query");

Questions about count optimizations:

optimize mysql count query

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.