```$ time python3 queries.py found 6812 userids $...
# troubleshooting
x
Copy code
$ time python3 queries.py
found 6812 userids

$ time python3 queries.py
found 6782 userids

$ time python3 queries.py
found 6895 userids
m
Can you remove the
having
clause to check if the result becomes consistent?
x
ok will try
yes, removing the
having
clause gives me deterministic results
the query becomes a low slower and i need to increase the
limit x
of the query and do the filtering on the client side though
We can also push certain having clauses to be processed on the server side (instead of on the broker side after merging all the results for each group) to reduce the amount of data sent from server to broker.
is this the reason for nondeterminism?
m
It could be because of that or because the servers may be trimming results before sending back to broker.
That happens in case of low selectivity queries.
x
another data point: if the
cell between 500 and 550
is reduced to a smaller range, i get deterministic results
in any case for my use case i always want deterministic results. is there a configuration or some other statement i can add to the sql statement to ensure this?
btw, i am running this with the docker-compose quickstart on my machine, so it’s just one server/container
m
try increasing the
limit
in your query
x
i tried that and it works! although it’s kind of non-intuitive that the final result (6k) is less than 10k, but increasing the limit to 100k increases the final result to a deterministic value (42k)
thanks for your help @Mayank
i would’ve thought that
limit
is applied after
group by + having
curious for the rationale where it is applied before
m
Yeah, the reason for trimming is in the broker log, see the
numDocsScanned
Your query is selecting
1039299
rows
x
i think i’m missing something. how did the number 1,039,299 clue you in when my limit is 10,000?
Copy code
# with the increased limit of 100k

Processed requestId=90,table=events_OFFLINE,segments(queried/processed/matched/consuming)=198/198/198/-1,schedulerWaitMs=0,reqDeserMs=1,totalExecMs=1331,resSerMs=2,totalTimeMs=1334,minConsumingFreshnessMs=-1,broker=Broker_172.21.0.4_8099,numDocsScanned=3116947,scanInFilter=624231605,scanPostFilter=3116947,sched=fcfs

# with the previous limit of 10k

Processed requestId=91,table=events_OFFLINE,segments(queried/processed/matched/consuming)=198/198/198/-1,schedulerWaitMs=0,reqDeserMs=0,totalExecMs=1159,resSerMs=1,totalTimeMs=1160,minConsumingFreshnessMs=-1,broker=Broker_172.21.0.4_8099,numDocsScanned=3116947,scanInFilter=624231605,scanPostFilter=3116947,sched=fcfs