Tamil Rk

Tamil Rk

  • 1.3k
  • 451
  • 17.6k

how to customize any other way to query

Jan 3 2022 11:42 AM

Hi team,

I'm trying to optimize this query size and best method, please let me share if have any best ideas on this optimize.

select '0sce to 2sec' as Bucket_Name,count(*) from tbllog 
where DATE_PART('second', endtimestamp::timestamp - starttimestamp::timestamp) <=2 and Process= @Process and  starttimestamp >= @StartTime and starttimestamp < @EndTime Union select '2sec to 5sec' as Bucket_Name,count(*) 
from tbllog  where Process= @Process and starttimestamp >= @StartTime 
and starttimestamp < @EndTime and DATE_PART('second', endtimestamp::timestamp - starttimestamp::timestamp)<=5 and DATE_PART('second', endtimestamp::timestamp - starttimestamp::timestamp)> 2 Union select '5sec to 10sec' as Bucket_Name,count(*) 
from tbllog   
where Process= @Process and starttimestamp >= @StartTime and starttimestamp < @EndTime and DATE_PART('second', endtimestamp::timestamp - starttimestamp::timestamp)<=10 
and DATE_PART('second', endtimestamp::timestamp - starttimestamp::timestamp)> 5 Union select 'Greater than 10sec' as Bucket_Name, count(*) from tbllog  
where Process= @Process and starttimestamp >= @StartTime and starttimestamp < @EndTime and DATE_PART('second', endtimestamp::timestamp - starttimestamp::timestamp)>10 ) 
ORDER BY Bucket_Name

Thanks


Answers (1)