Aditya Verma
01/13/2025, 8:21 PMdataTrunc
that my timestamp : 1761140649
Wednesday, 22 October 2025 13:44:09. after conversion
so if I want to use Timestamp index should I use it ? If yes then
what kind if query do I have to write in dataTrunc
@Xiang Fu has mentioned this in one thread
Just be aware that pinot index is local to the segment, so if your single segment would have data span across multiple days or months then you will get benefit
otherwise the query will match the entire segment, then no index is needed.
Rena
oh okay.I have two segments .Each segment contains data for one month.(With little overspill of neighbouring months data) .In that case, if i am i use a range filter for each month in my query , the entire segment is scanned for each month respectively.So in that case the query will show the same performance with and without the range index.Am i right?
Xiang Fu
correct
I would prefer to have daily segment
Rena
i dont quite understand,how will daily segments help to increase efficiency with range queries? (edited)
Xiang Fu
you will filter less data cause the 29 days are within the predicate and you only need to deal with the 2 boundary days, so you are scanning at most 32 days data
Can anyone throw some light, on it mostly I will time range queries of upto 6 months .
SELECT SUM(chipStackStart),userId
FROM game_hands_data
WHERE gameStartTimestamp >= 1729999985 AND gameStartTimestamp <= 1759999985
group by userId
how can I use timestamp index and how will the query formulate if I have to use dataTrunc functions
something like this ?
SELECT SUM(chipStackStart),userId
FROM game_hands_data
WHERE datetrunc('Month', gameStartTimestamp) >= 1729999985
group by userIdXiang Fu
datetrunc('Month', gameStartTimestamp) should workXiang Fu
Xiang Fu
Aditya Verma
01/14/2025, 7:16 AMXiang Fu
Xiang Fu
Xiang Fu
Xiang Fu
Aditya Verma
01/14/2025, 8:42 AMXiang Fu
correct
I would prefer to have daily segment
Rena
i dont quite understand,how will daily segments help to increase efficiency with range queries? (edited)
Xiang Fu
you will filter less data cause the 29 days are within the predicate and you only need to deal with the 2 boundary days, so you are scanning at most 32 days data
I was actually following your thread and you mentioned this so if I have a range partition for 3 months that is 90 days then its better to use granularity for months or for days ?
as you mention here day is Better. Just wanted to understand how and why ? if you can throw some light on that @Xiang FuXiang Fu
Xiang Fu
Aditya Verma
01/14/2025, 7:03 PMXiang Fu
WHERE clause?Xiang Fu
WHERE datetrunc('Month', gameStartTimestamp) then you put month into timestamp index granular
if your query is like WHERE datetrunc('Day', gameStartTimestamp) then you put day into timestamp index granularAditya Verma
01/14/2025, 7:21 PMSELECT SUM(chipStackStart),userId
FROM game_hands_data
WHERE gameStartTimestamp >= 1729999985 AND gameStartTimestamp <= 1759999985
group by userId
My query looks like this and this timestamp is an epoch time stamp .
Its based on the use case :
if customer wants to see his last day stats then where clause might have only for last day
customer can also ask for last week , last month and last 3 months and upto last 6 months .
Our UI gives the customer facility to look for such a time range.
so a raneg query could be
WHERE gameStartTimestamp >= current_timestamp(1729999985) AND gameStartTimestamp <= last 3 months(1759999985)