linq to sql - Hitting the 2100 parameter limit and how to improve this query? -
i have complex search system gets list of matching courses, shows list of filters (career paths) number of courses each filter option. after have list of search results, query list of career paths , how many courses have career path (a course can have multiple career paths , courses can associated career paths courseversionid or courseinfoid (sounds strange there's reason). can't change database structure @ point looking ways improve query.
if there lot of search results (1200) hit 2100 parameter limit due 2 contains sections of query. can avoid problem limiting results 1000 hoping there better way query.
tbcareerpath list of career paths cache complete list (about 50) in memory save on lookups.
tbcoursecareerpath lookup table has fields associate courses either courseversionid or courseinfoid (hence 2 contains).
courseresults search results list, anywhere 1500 results (unusual happens).
here's query career paths have courses in search results, , number of courses:
var q2 = careerpath in tbcareerpath.cache() let coursecount = ( coursecareerpath in dc.tbcoursecareerpaths coursecareerpath.careerpathid == careerpath.careerpathid && ((from course in courseresults select (int?)course.course.courseversionid).contains(coursecareerpath.courseversionid) || (from course in courseresults select (int?)course.course.courseinfoid).contains(coursecareerpath.courseinfoid)) select coursecareerpath ).count() coursecount > 0 orderby coursecount descending, careerpath.careerpathtitle ascending select new filter() { id = careerpath.careerpathid, title = careerpath.careerpathtitle, recordcount = coursecount };
Comments
Post a Comment