26 Jun 2023 11:10 AM - edited 26 Jun 2023 12:23 PM
There is a difference between using the startTime/endTime in the WHERE clause and the Global time frame in the USQL.
USQL Global timeframe filter in WebUI will match all user sessions that were active between from and to time.
That means it will match all user sessions that started and ended within the timeframe filter, all user sessions that started before the timeframe and ended within the timeframe, all user sessions that started within the timeframe and ended after the timeframe, and even all user sessions that started before the timeframe and ended after the timeframe
and when you use the endTime where clause this will match only sessions that have the last useraction timestamp within this timeframe added in the query
or
when you use the startTime where clause this will match only sessions that have the first useraction timestamp within this time frame added in the query
Example:
08:30 09:30
timeframe filter |-----------------------------------------------|
session 1 |----------|
session 2 |-------------------|
session 3 |---------|
session 4 |---------------------------------------------------------|
With Endtime (in the uSQL query):
SELECT COUNT(*) FROM usersession WHERE endTime > 1687422600000 AND endTime < 1687426200000
using the Where clause endTime count will be - 2 (session 1 and session 2)
Without Endtime (timeframe was set at the Global level 8:30 to 9:30 June 22)
SELECT COUNT(*) FROM usersession
using the Global time frame count will be - 4 (all 4 sessions)
Side note:
If you want to have the global timeframe behaviour expressed as a filter, "all sessions active between 8:00 and 9:00" could be represented as "endTime after 8:00 and startTime before 9:00"
The options are:
Reason for picking that option for the global timeframe: It includes most session; if you are interested in any other option, you can add the according filter.
If we had used any other definition, e.g. session 4 would never appear, despite it was active during the whole timeframe and there would be no way to see "all active sessions".
Maybe related:
When you use
SELECT ... from usersession WHERE useraction.startTime ...
it matches all sessions where AT LEAST ONE useraction matched your criteria; and you'll get all matching usersessions.
SELECT DISTINCT useraction.starttime from usersession WHERE useraction.startTime > 1687422600000
may still return you starttimes that are below the value.
This feature is nice for co-occurrence analysis. If you are just interested in useractions, use
SELECT ... from useraction WHERE [useraction.]startTime ...