| Bug #65723 | MySql Provider for EntityFramework produces "bad" SQL for OrderBy | ||
|---|---|---|---|
| Submitted: | 24 Jun 2012 19:31 | Modified: | 28 Jun 2013 2:41 |
| Reporter: | sanosay sanosay | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | Connector / NET | Severity: | S1 (Critical) |
| Version: | 6.5.4.0 | OS: | Windows |
| Assigned to: | Gabriela Martinez Sanchez | CPU Architecture: | Any |
[24 Jun 2012 19:31]
sanosay sanosay
[8 Aug 2012 6:52]
Grzegorz Sawicki
I have a similar case:
sum = (from k in db.sys_godzinne_serw
where k.Type == 1 && k.ID_Serwis == ID
select k.Wartosc).Sum();
produces sql:
SELECT
`GroupBy1`.`A1` AS `C1`
FROM (SELECT
SUM(`Extent1`.`Wartosc`) AS `A1`
FROM (SELECT
`sys_godzinne_serw`.`Type`,
`sys_godzinne_serw`.`ID_Serwis`,
`sys_godzinne_serw`.`Wartosc`,
`sys_godzinne_serw`.`Brow_Opera`,
`sys_godzinne_serw`.`Brow_Msie`,
`sys_godzinne_serw`.`Brow_Firefox`,
`sys_godzinne_serw`.`Brow_Netscape`,
`sys_godzinne_serw`.`Brow_Konqueror`,
`sys_godzinne_serw`.`Lang_PL`,
`sys_godzinne_serw`.`Lang_EN`,
`sys_godzinne_serw`.`OS_Windows`,
`sys_godzinne_serw`.`OS_Linux`,
`sys_godzinne_serw`.`ChSet_Utf8`,
`sys_godzinne_serw`.`ChSet_Utf16`,
`sys_godzinne_serw`.`ChSet_Iso_8859_1`,
`sys_godzinne_serw`.`CreatedAt`
FROM `sys_godzinne_serw` AS `sys_godzinne_serw`) AS `Extent1`
WHERE (1 = `Extent1`.`Type`) AND (`Extent1`.`ID_Serwis` = 741)) AS
`GroupBy1`;
Execution time: 75 seconds (very big table)
manual SQL:
select sum(Wartosc) from sys_godzinne_serw
where type = 1 and id_serwis = 741
Execution time <1 second
This is very critical bug !!!
[28 Jun 2013 2:41]
Philip Olson
Fixed as of the upcoming Connector/Net 6.5.7, 6.6.6, and 6.7.4 releases, and here's the changelog entry: Generated "LINQ to Entities" queries are no longer as nested. In other words, two similar queries with one nested inside the other are now flattened into a simple query. This provides better performance for large result sets. Thank you for the bug report.
[10 Aug 2015 8:06]
Silvi Alam
is it solved really because i got Connector/Net 6.9.7 release and it still generates nested SQL query and of course the ‘where’ clause and ‘order by’ clause are on different select statement which makes a huge performance issue in our case for 100k records. Is there any suggestion to get around it? Regards, Silvi
[1 Jul 2016 8:05]
roarker roarker
The same issue, it's still not fixed in 6.9.8
