As I understand, you have millions of records in a database, and you need very good performance from your application, and you have very complex structure.
Stay away from EF and I mean it. You can use it for smaller datasets, but for anything that requires superb performance from a huge query, don't even go there.
My suggestion is to write the queries manually, because if you wanted to optimize as much as you could with EF, you would practically not be able to skip much code anyway and would basically be writing SQL in LINQ way (ie specifying all SELECT statements).
If you want a little bit more specific, use Dapper. It's the "ORM" that runs StackOverflow. There's comparisons on speed here: http://code.google.com/p/dapper-dot-net/
However, if you're dead set on using EF...
Don't try to write one query. It won't happen. Instead, split them. Take a different one for each group that you need to make. It's by far the easiest way out. I believe you should already have a LINQ query for getting just one group out. Now repeat that with every other group you need, especially if you have a ton of Wheres and OrderBy's in it.
Source: a guy that works with large dataset queries daily.
- Advanced LINQ Grouping and Projection Query for Hierarchical Data (EF 4.0 + LINQ + ASP.NET MVC + HighCharts)
- LINQ that groups data and returns series for chart
- Highcharts - Global configuration with common code and unique data & Headings
- Sql query to populate 0's for missing data
- Data with timestamp group to month(like Jan, Feb, March) and showing as total count for month in Highcharts
- Check all charts for data and hide ones that have none
- Make Highchart and Highstock Have a Uniform Time X-Axis for Disparate Data Points
- Highcharts series showing different data for 'column' and 'line' chart
- Django query database and send data to template
- How do I calculate the total Data values for both and display in Legend
- Output query data in other format for chart to recognize
- How can I use data.table or data.csv and extra data for click event handling
- Highcharts display label for pie chart using html table as data source
- Convert and Sort Data for HighChart Column Range Representation
- How to dynamically adjust dataGrouping and set variable time intervals for HighStock data (HighCharts)
- Data and tooltip not working for graph using highcharts
- Highcharts how to make a set number of colors for pie chart data and drilldown data
- In highchart of column type and xaxis of datetime type showing more ticks for month data
- Set a maximum for data grouping in Highstock charts to prevent from grouping
- Two DataSeries for yAxis 1 and 2 with Data from SQLdb
- How to get data for series and categories in highcharts-convert.js from mysql
- HTML table as data source for highstock charts using highcharts
- set minimum and maximum values for axis' data in highchart
- I'm trying to use HighChart map and solid guage they both work for my data independetly but I get get lot of errors on I put them on a file
- Data Conversion from SQL, C# with Linq to JSON for Highcharts Line chart
- Using a flask variable as data source for highcharts
- Complicated Rails query for reports with missing data
- Need help in simplifying the code to synchronise tooltips and crosshairs for Highcharts,
- How to plot map and data with respect to zipcodes/neighbourhoods for amsterdam
More Query from same tag
- Highcharts: enforce options when adding a serie with addSeries
- High Chart line single data set but multiple color, not gradient color
- Highcharts (highstock) anyway to detect maximum value in a series
- Google AdWords Location Criterion Id to ISO 3166-2
- Parsing string array into chart
- Jasper report color issue with Highcharts's plotOptions.fillColor
- Highchart Color Issue for series with single data with multiple colors
- Multiple categories for hc_yAxis
- how to remove negative symbol from negative y-axis on highcharts/highstock
- How to change gauge meter color based on value in highcharts
- Highcharts: Remove shadow from center of donut chart
- Highcharts Stacked Percentage Column Hyperlink
- Highstock Change tick interval on range selector change
- legendItemClick not getting triggred after changing chart type
- Tooltips don't clear on IE8
- Combining gantt chart and line chart using highchart
- Adding a comment box to a web page
- Highcharts logarithmic chart not displaying series on webpage
- Combine multiple Ajax load functions
- Setting Order of R Highcharter Categories
- Highchart limiting number of series by default
- highcharts add percent sign in data values
- How to create a range between series?
- Highcharts Datetime X-Axis invalid date
- Highcharts map doesn't change color on hover
- Trying to set xAxis extremes using highcharts-vue wrapper
- Highcharts Gauge styling and adding CSS elements
- What's the angular way to handle redraws?
- Converting laravel raw SQL queries to collections