Total Record Count

Total Record Count

Old forum URL: forums.lhotka.net/forums/t/5046.aspx


Zafar Ullah posted on Wednesday, July 02, 2008

Hello,

I am using CSLA.NHibernate from CSLA Contrib.

I am using CSLA version 3.0.4.0 and CSLA.NHibernate version is compiled using the same version of CSLA and my application is web based(ASP.NET with C#)

I have a huge number of records to display in our database e.g over 20 million and above in some tables rest of them are under 1 lac. I hav implemented paging and a max of 100 records can be shown displayed in a grid at 1 time.

Actually what we do is we send call to Collection class to load all records which meet under certain search criteria and take its count. like this

AMCollection.GetAMCollection(crit).Count

In background NHibernate make objects of  all records e.g 1million and then we have a count. which make web page response very slow over 30 sec.

Is there any way to take the total count with out making objects of each record that NHibernate pulls.

Thanks in advance

Zafar Ullah

chrisghardwick replied on Friday, February 25, 2011

I might go in a different direction. Maybe count the rows in the database, and return the result. This would perform much better, and would make the application more responsive.

bniemyjski replied on Monday, April 18, 2011

Hello,

I'd recommend creating a stored procedure that returns the count and maybe a generic Command Object that takes the table name and calls this stored procedure.

Thanks

-Blake Niemyjski

Copyright (c) Marimer LLC