Go Back

What is the difference between SORT BY and ORDER BY in Hive?

10/26/2022
All Articles

#hive sql group by order by #percentile over order by hive sql #hive sql order by limit #order by and sort by in hive #bigdata #hadoopHive #hivequery

 What is the difference between SORT BY and ORDER BY in Hive?

ORDER BY and SORT BY Clause in Hive

Here we can create a Table and  perform live operation .

Follow all steps which is as follow :

Creating table 

create table DeveloperIndian(Id int, Name string , Salary float, Department string)    
row format delimited    
fields terminated by ',' ; 
 

Load the data into the table.

load data local inpath '/home/codegyani/hive/developerIndian_data' into table DeveloperIndiavn; 

 

Run the order by Query

ORDER BY performs a total ordering of the query result set. This means that all the data is
passed through a single reducer, which may take an unacceptably long time to execute for
larger data sets.
 

select * from DeveloperIndian order by salary desc;

 

Run the Sort by Query

SORT BY orders the data only within each reducer, thereby performing a local ordering, where each reducer’s output will be sorted. You will not achieve a total ordering on the dataset. Better performance is traded for total ordering.
 

 select * from DeveloperIndian sort by salary desc;

 What is the difference between SORT BY and ORDER BY in Hive? hive sql order by limit , order by and sort by in hive

 

Article