Thursday, March 22, 2012

Does RS use ORDER BY for grouping?

It seems like you don't need to specify SQL's ORDER BY to match Page and Group breaks in RS. I.e., RS does
this handling by itself, with the added work and memory requirements to do it.
My question is whether RS will understand that I do have ORDER BY in the query that matches my Page and Group
breaks, and just read off the input stream without doing the sorting etc by itself. If it doesn't, I wouldn't
want to burden the DBMS with the sorting as it would be redundant...
I tried a report, which was indeed alphabetically grouped by RS without a SQL ORDER BY. Even when adding ORDER
BY NEWID() (which returns rows in a different "random ordering for each execution), the report was still
grouped alphabetically.
(I am not referring to the ordering of the details info, I understand that ORDER BY is needed for that.)
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/You don't ever need to use ORDER BY in your query, even to order the
details. RS supports many different types of data sources (and you can
easily add your own by writing a custom data processing extension), not just
SQL, and some these data sources may not have the ability to sort. Also, RS
does not examine your query and cannot detect that you have an ORDER BY.
--
Rajeev Karunakaran [MSFT]
Microsoft SQL Server Reporting Services
This posting is provided "AS IS" with no warranties, and confers no rights.
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:OPN1N6ifEHA.1644@.tk2msftngp13.phx.gbl...
> It seems like you don't need to specify SQL's ORDER BY to match Page and
> Group breaks in RS. I.e., RS does
> this handling by itself, with the added work and memory requirements to do
> it.
> My question is whether RS will understand that I do have ORDER BY in the
> query that matches my Page and Group
> breaks, and just read off the input stream without doing the sorting etc
> by itself. If it doesn't, I wouldn't
> want to burden the DBMS with the sorting as it would be redundant...
> I tried a report, which was indeed alphabetically grouped by RS without a
> SQL ORDER BY. Even when adding ORDER
> BY NEWID() (which returns rows in a different "random ordering for each
> execution), the report was still
> grouped alphabetically.
> (I am not referring to the ordering of the details info, I understand that
> ORDER BY is needed for that.)
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
>

No comments:

Post a Comment