Looks like SQL query is not cached, and equivalent dsl qeury is cached.
Every single time this SQL query is executed, it takes over 3 seconds. (The number of documents is about 6,000,000)
POST /_sql?format=json
{
"query": "SELECT HISTOGRAM(\"batchDate\", INTERVAL 1 DAY) AS \"h_date\", SUM(\"aggrCount\") AS \"cnt\" FROM \"my.index-*\" WHERE \"batchDate\" < 1560988799999 AND \"batchDate\" >= 1560340034000 GROUP BY \"h_date\""
}
And when I'm using QueryDSL using request body got from /_sql/translate API with the sql query above, it took over 3~5 seconds only first time, and next it took under 1ms. Maybe it might be cached.
@c81b4c93b1f70af5398f the json we generate as a query can be different every time you call translate. The relevant parts of the query will not be different, obviously, but the name of the aggregations, for example, can be different - 25579 and 25580 from your example. And I think caching works on the body of the query (the json itself). If you generate the query once, run it several times, and then generate it again with translate and run it, does it take seconds or returns instantly?
The name of aggregations depends like you mentioned in translate API.
I repeated the query dsl request several times after generating translated json body(dsl) once, and it got much faster after several times. But it gets fast only with translated dsl that has same name of aggregations. If I generate new translated json body(with another aggregation name), it takes long again.
When it comes with SQL, It takes over 3 seconds even after several times.
Can I fix the name of aggregations when requesting by SQL?
Thank you very much for quick respond my configuration is look like below . appciate if you can help me to setup 3 node cluster . I'm going go update my 3 node production cluster from v 6.5.1 to v 7.1.1
@c81b4c93b1f70af5398f no, you cannot control the name of the generated aggregation in a query, everything is transparent and ES SQL should behave just like any other SQL facing tool.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.