I was reading about Timestamp index and read in on...
# troubleshooting
a
I was reading about Timestamp index and read in one of the threads it only works with
dataTrunc
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 userId
x
yes
datetrunc('Month', gameStartTimestamp)
should work
the query will be rewritten to use the index
a
I see and how do I put it on epoch time ?? Also you mentioned to use days vs month What does it actually means ?
x
You configure timestamp index in table config following the docs
Then reload table
Then run the same query with dateTrunc
In the index config you can configure the granular you want to use in the query, Pinot will build index for those granular like DAYS or MONTHS
a
Copy code
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
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 Fu
x
you can configure multiple granulars, this is based on your query
if your query has DAYS then your configure day granular in the timestamp index, if you query has MONTHS then you configure month granular in the timestamp index
a
I see so if my date range is for days like past 60 days and not 2 months then days other wise if it has range between months than index should be months , right ? but lets say if someone says for last 2 months and my date is jan 15 today so last 2 months would be Nov 15 . but the granularity is of months so it will read all the segments for the for January and December and November as well so instead of 60 days it goes over 90 days and then shorten it down to 60 days. Am i right in this understanding
x
no, index is working on queries, can you tell me how you want to query the data in your
WHERE
clause?
if your query is like
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 granular
a
SELECT 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)