MarcoP wrote:
Otis wrote:
Indeed, specify Distinct() to get server-side limiting if duplicates can occur. It otherwise switches to client-side limiting. Distinct is recommended, because duplicates ruin the limiting.
This is actually wrong (as in: not necessary), which we have corrected in v3.1, which goes into beta later this week.
Hmm....Based on my tables containing 6million and 1 milllion rows, how do you think the client-side would perform (I am sure no duplicates come back)? Wouldn't the server-side performance be very expensive with this amount of rows??
Worse case, is there a way I can add this to the generated sql?
Client side is simple: it simply reads n rows from the datareader and then closes it. This is equal to SELECT ... FROM ... LIMIT x; with the difference that the server will 'load into memory' more rows for the client-side version.
That's also why we made the change. Distinct is recommended to get suitable results (fetching 10 rows which are all duplicates makes no sense).
If distinct is slow in your RDBMS, we added to 3.0 a setting to always do client-side distinct filtering:
DynamicQueryEngineBase.DistinctFilteringPreferenceDefault = DistinctFilteringPreferenceType.AlwaysClientSide;
(default is 'System', which is the behavior where distinct filtering is done on the server, unless it's impossible to do otherwise (as it will generate an error)).
This will simply mean that distinct filtering is done on the client, per row values are hashed, and if a duplicate row is detected, it's thrown out. This is done per-row on the datareader, so it could make things perform better, as it doesn't go through the whole resultset first.
After posting I saw you are still on v2.6. It's doable but not ideal. You could modify the MySQL DQE a bit to always switch to client side distinct filtering (by setting the flag on the IQuery object, see sourcecode).