I've noticed that in the LLBLGen documentation, the recommended paging approach involves performing a GetScalar function first to determine the total number of records, then passing that record count parameter into the FetchTypedList to facilitate paging on large datasets.
My problems are two-fold:
1) Performing the GetScalar function takes just as long to calculate the number of records as it does to return all the records with data. Granted, I have a dynamic TypedList with 8 relations and 16 fields, but should that really make any difference?
Needless to say, for performance reasons I'm pulling all the records that matched the query and having my search result screen perform the paging. Am I doing something wrong?
2) The search must perform a LIKE across 10.5 million characters of text, and filter based off of other search parameters, so it takes a noticeable amout of time to perform the search. Is there a way to force LLBLGen to execute the filtering parameters first, then the LIKE statement? I'm seeing a huge performance hit because it performs the LIKE statement across all the data and then filters on the other parameters.
Here's the code that I'm currently using to track performance and perform the query. Notice I'm just returning all the results instead of using the GetScalar. I'm leaving out the field definitions and relations for readability.
BestPracticeSearchResult searchResult;
using (DataAccessAdapter adapter = new DataAccessAdapter()) {
// Start the timer
DateTime startTime = DateTime.Now;
// Retrieve the items to display on the current page
DataTable searchResultItems = new DataTable();
adapter.FetchTypedList(fields, searchResultItems, bucket, 0, sorter, false, null, 0, 0);
int itemCountTotal = searchResultItems.Rows.Count;
// Stop the timer
TimeSpan searchTime = DateTime.Now - startTime;
// Create the search result
searchResult = new BestPracticeSearchResult(pageNumber,
itemCountPageMax,
itemCountTotal,
searchTime,
searchResultItems);
}
Any help is greatly appreciated! Thanks in advance!