The Best Query Language to Use with InfluxDB

Navigate to:

People often ask us, “What is the best query language to use with InfluxDB?” The answer to this question has evolved a bit over the years – and the current answer might surprise you.

The early days

InfluxDB’s first query language was InfluxQL. InfluxQL is a SQL-like language with some enhancements specifically designed for time series data.

It was far and away the best query language to use with InfluxDB because it was the only query language you could use with InfluxDB. It is very popular and still in use today.

Flux arrives

Even with the success of InfluxQL, we recognized that our users would benefit from something more advanced than SQL-like querying. We wanted something that allowed our customers to perform operations right at the database level. So we built a complete scripting language called Flux. You can do all sorts of things with Flux like:

  • Combining data sources by pulling in or referencing data from a relational database using the sql.from function

  • Writing back to a relational database using the function

  • Performing simple or complex downsampling or aggregations

  • Making outbound API calls to trigger action(s) in your own applications

We continue to be very excited about Flux (check out the Flux 1.0 announcement!) and consider it a real differentiator for us. At the same time, we recognize that Flux isn’t necessarily for everybody. It has a learning curve and not everyone is willing to invest the time it takes to learn the language. But if you ask an Influxer, we’d probably tell you that Flux is the best query language to use with InfluxDB.

InfluxDB IOx

With our recent announcement of InfluxDB IOx, we introduced native SQL querying language support as well.

For organizations with IOx-enabled buckets, you can choose from InfluxQL, Flux, and SQL to query your data. So, since we announced SQL support, does that mean that SQL is the best language to use with InfluxDB? The answer, as it often is: it depends.

So what do I choose?

We are bullish on SQL as a query language in InfluxDB and feel it is a great choice in many circumstances, like:

  • You’re migrating code that already makes PostgreSQL calls to a different SQL database.

  • You know SQL really well and don’t have time to learn a new tool.

  • Your primary needs involve querying data and data transformations, and other operations are not as important at this time.

But InfluxQL still has its place and is good in many other situations, like:

  • You like the SQL-like experience but want the time series extensions that come with InfluxQL.

  • You already wrote a lot of query scripts using InfluxQL and don’t want to migrate them.

  • You love InfluxQL!

And Flux is certainly a winner when you want a full-fledged scripting language that can do advanced operations at the database level beyond what you can do with a simple query language.

Rather than recommending or promoting a specific language, we continue to abide by our mantra of “meeting developers where they are.” When it comes to querying data in InfluxDB, we give you multiple options, in the hope that at least one of those options is right for you based on your own environment and work experience. And it isn’t always about choosing just one query language. Some users may want (or need) to utilize a combination of the supported query languages.

But we aren’t simply content with these three language options either. For writing tasks that run on the InfluxDB platform, we also plan to add support for Python and Javascript. This will give you even more options for creating tasks and let you leverage your existing skills in the process.

So, while you might have expected me to say that Flux is the best query language to use (we do think it is really awesome), or maybe you thought I would say SQL is the best query language to use because our IOx engine supports it, I am not. Those are, in fact, two terrific options, and InfluxQL is a third. The bottom line is that you know your environment best and probably already have a good idea of what the best fit is for you. With that in mind, my official recommendation to you is:

The very best query language to use with InfluxDB is whatever you choose to use.