See SQL for Custom Query

(I’m sure this has been answered elsewhere, I just can’t find it. I may need another coffee or three.)

Is there a way to see the SQL that is generated for a “Custom” query?

I"m curious, because I have a simple query that runs in a second if I write native SQL:

select product_id, count(*)
from order_detail
where order_date > now() = interval '3 days'
group by product_id

But when I build the same query using the custom query builder, I end up killing it after 30 seconds.

So I’m wondering if I’m not using the custom builder properly, or if it is doing something unexpected under the covers.

Hi @ccurvey

Until you see it, then you’ll kick yourself for not seeing it :wink:

It’s the “Switch to SQL” button on 0.32 just above the query browser. It’s called “View the SQL” on the upcoming 0.33 and is inside the Editor (aka Notebook) panel.
But it’s only active/visible after you run the query.

I’m fairly sure you’re seeing the issue where order_date is treated like CAST(order_date AS DATE), which means it doesn’t use the indexes, but I’ll wait with a link until you have confirmed (or posted the query).