This message was deleted.
# troubleshooting
s
This message was deleted.
b
What's the query, and the full error?
s
@Krishna hi, in order to evaluate a HAVING clause, final aggregation must first be achieved and final aggregation is completed on the Broker. If you share you query perhaps we can recommend changes that would improve the overall performance and still achieve your objective.
k
sure @Sergio Ferragut @Ben Krug we are not seeing any errors but cluster will be busy and causing slowness to small queries also
b
Oh, well sample query could help. I guess not error, I was asking about this: "When we try to keep
forcelimitPushDown
to true it is failing saying this setting won’t applicable if we have having clause ." What's the full message?
I agree with Sergio. I just wondered what the query and HAVING clause were.
k
sure
@Ben Krug this is the sample query that failed
s
how about rewrite with:
Copy code
SELECT * FROM
( 
SELECT sum(metrics) as sum_metrics FROM "druid"."datasource"
WHERE ...
LIMIT 10
)
WHERE sum_metrics > 0
This should run the subquery with the pushdown and then resolve the "having" with the external WHERE clause.
k
let me check
still same error Error: Unknown exception Cannot force limit push down when a having spec is present. org.apache.druid.java.util.common.IAE
s
That is weird, I tested the query on Apache Druid 25.0 and it worked. what version are you on? Another point for this particular query is that the LIMIT won't do anything because it produces a single result per segment which then gets merged in the broker to a single result, so there is nothing to limit.
Are you running from Druid Console? What is your query context?
b
OK, looking at it, it makes sense to me now. We generally can't evaluate the HAVING at the historical, because we need the totals first. For this particular query, it's logically possible, but the planner's not detailed enough to see that.
k
Druid version is.21
Yes running from console
b
It's not going to work like that with forcing limit pushdown to historicals. Druid can't properly evaluate a HAVING with partial results. For this particular query, I might have a workaround...
k
Ok
b
actually, this is just an example to show the error, right, not a real query? For a real query I probably won't have any workaround. Do you have a real one?
k
Will get one actual query
g
if you need precise control over exactly what is and isn't pushed down, you could also use the native query API instead of SQL
since then you could provide different contexts to different subqueries, if you want
issue with the SQL approach is the context is applied to all queries and subqueries individually, and I think in your case it doesn't make sense for all of them
SQL also rewrites things; as you can see in an example earlier, it fused a
WHERE
on a subquery into a single query using
HAVING
. It does this kind of rewriting without considering context params like
forceLimitPushDown
k
for testing we can use native API but our application use avatica sql to query druid
b
Is there a reason not to set forceLimitPushdown to false in the query context for these queries? I think you could do that, and leave it true for other queries.