473,379 Members | 1,278 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 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 2172
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,556 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 pa02101,pa01601 where
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, N.W., Washington, DC 20009-1277. The meeting starts...
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 order. Is this something that most RDB's have...
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 10/6/1999 7890 58741 6/21/1992 I...
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 (does not contain member property), or 0. Using...
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, properties etc.? If yes: what ordering scheme do...
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 EMPLOYEE Table consists of a salary and job_title...
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 -- connected to the sample db SELECT WORKDEPT,...
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); but this will also sort the array which will get...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.