Thanks fabio. I thought of that, but I'm concerned that (using your example 1000 limit):
a) I need to sort the data via an order by. If I'm going to keep the first 1000 then SQL will need to retrieve all the possible rows, then sort them to get the top 1000. There may be a lot of work for SQL to do to get these top 1000 (we have a lot of data to work through and the queries are potentially complex). This step isn't necessary for a count. b) Its part of an overall performance improvement to an existing system. The system does not show the first 1000, it shows an error message and tells the user to try again. If I keep the same UI process, the solution you suggest will force NH to pull back 1001 rows from the database, over the network, load up the objects, show the message and then discard them. Seems a bit pointless and a waste of resources. I could force a change to the UI though to keep the 1000 rows and display them no matter what... but then I'm stuck with the problem of (a).... i.e. doing an order by on many thousands of rows just to get the first 1000. Diego: It's not exactly doubled but if the initial count takes (for example) 3.0 secs without the order by, the main query takes about 2.5 secs with an order by... total time about 4.5 secs. The second query only takes 2.5 secs because I know I'm doing on a limited set of data (i.e. not thousands of rows). It also has a slightly different structure as I'm returning data whereas the count query does not. -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
