472,328 Members | 2,102 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,328 software developers and data experts.

GROUP BY also means SORT

2
Hi to all,

DB2 seems to do a SORT before every GROUP. At least if I look at the query plan of

Expand|Select|Wrap|Line Numbers
  1. -- connected to the sample db
  2. SELECT WORKDEPT, SUM(SALARY)
  3. FROM EMPLOYEE
  4. GROUP BY WORKDEPT
  5.  
a SORT is performed before GRPBY. I can imagine that it's necessary, but why?

Greetings, Martina.
Nov 29 '06 #1
3 2067
r035198x
13,262 8TB
Hi to all,

DB2 seems to do a SORT before every GROUP. At least if I look at the query plan of

Expand|Select|Wrap|Line Numbers
  1. -- connected to the sample db
  2. SELECT WORKDEPT, SUM(SALARY)
  3. FROM EMPLOYEE
  4. GROUP BY WORKDEPT
  5.  
a SORT is performed before GRPBY. I can imagine that it's necessary, but why?

Greetings, Martina.
Hi, how did you check that a sort is performed before the groupby?
Dec 1 '06 #2
mmmm
2
I use Visual Explain within the Command Center.
Dec 1 '06 #3
NeoPa
32,511 Expert Mod 16PB
This is quite standard in SQL generally.
The engine has to process through the input somehow.
If it can process through by a relevant key then it will - otherwise it has to sort before it can tell if the next record is part of 'this' group or the beginning of the next.
Dec 4 '06 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: AJ | last post by:
Hi , I have this query paprojnumber is varchar patx500 is text palineitemseq is int select Paprojnumber,Patx500,max(palineitemseq) from...
0
by: Betty Harvey | last post by:
The next meeting of the XML Users Group will be held on Wednesday, April 21, 2004 at the American Geophysical Union (AGU) at 2000 Florida Avenue,...
5
by: Mike Nolan | last post by:
I notice that 7.4 doesn't do default ordering on a 'group by', so you have to throw in an 'order by' clause to get the output in ascending group...
6
by: neptune | last post by:
I must be missing something obvious. I have 3 fields and sample data. 7890 26592 7/15/2003 7890 13645 ...
9
by: Terry E Dow | last post by:
Howdy, I am having trouble with the objectCategory=group member.Count attribute. I get one of three counts, a number between 1-999, no member...
12
by: Gerrit Beuze | last post by:
Hi all, I'm wondering if you how you organize as (in sorting / order) your C# class code: Do you sort/ group by member type: fields, methods,...
1
by: jim | last post by:
Hi, I was wondering if anyone out there can help me with this SQL problem: I have a database that has two tables: EMPLOYEE and JOB_TITLE The...
1
by: Martin.Molch | last post by:
Hello, DB2 seems to do a SORT before every GROUP BY action. At least if I look at the query plan (using Visual Explain in the Command Center) of...
2
by: William | last post by:
for example, there is an array: int a={2, 3, 1,3, 2,1}; i want to group it as: {2,2,3,3,1,1} , not care the order. i can use std::sort( &a, &a);...
0
by: tammygombez | last post by:
Hey everyone! I've been researching gaming laptops lately, and I must say, they can get pretty expensive. However, I've come across some great...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
1
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.