Slow queries when joining with SQL

Hello,
I’m following the docs about querying SQL data sources.
Separately, the SQL and InfluxDB data retrieval take less than 1 second.
When I perform the join (on a single id field, as in the docs example) the query takes about 30 seconds.
Is there something I can do to improve performances?
Thanks

Hello @eloparco,
Cool question!
Can you please provide your Flux query as well as a description of the data you’re returning from your SQL source?
Also, what are you doing with SQL + Flux? Sounds interesting. I’d love to learn more.

Hi @Anaisdg,
it’s basically something similar to the example in the docs. The solution that I found in my case consists in adding an aggregation for the InfluxDB data before the join with the SQL data, to reduce the number of joins needed.

Considering the example with sensors in the docs and the goal of getting the average temperature per sensor: instead of doing the join and then calculate the average, I had to group per sensor, calculate the average temperature and only then perform the join on the sensor_id field.

Of course, in my specific case, it wasn’t that easy. I needed to add an additional tag to do some aggregation before the join, but the point was still to reduce the number of joins through some grouping operations performed ahead.

Anyway, thanks for the interest! I’ve been working for a few months with InfluxDB and I’m finding a lot of useful resources here in the forum :slight_smile:

1 Like

@eloparco,
Great! I’m happy you found a solution.