opendistro-for-elasticsearch / sql

🔍 Open Distro SQL Plugin
https://opendistro.github.io/for-elasticsearch/features/SQL%20Support.html
Apache License 2.0
620 stars 186 forks source link

Support reading value from docvalue #947

Open jgq2008303393 opened 3 years ago

jgq2008303393 commented 3 years ago

Would Opendistro SQL support reading docvalue fields? When only a small number of fields are read, performance would be greatly improved. Looking forward to this feature!

penghuo commented 3 years ago

Thanks for reaching out. Could you give some example that how to use SQL to read docvalue?

jgq2008303393 commented 3 years ago

@penghuo Thank you very much for your reply. For GroupBy query, docvalue is used. So this issue mainly focuses on normal select query. IMO, there are two ways to do this:

SELECT DocValue('uid'), DocValue('timestamp'), DocValue('page_views') FROM index;
dai-chen commented 3 years ago

@penghuo Thank you very much for your reply. For GroupBy query, docvalue is used. So this issue mainly focuses on normal select query. IMO, there are two ways to do this:

  • The best way is to automatically choose whether to use source or docvalue based on SQL.
  • Another way is to allow users to choose to read from docvalue as follows:
SELECT DocValue('uid'), DocValue('timestamp'), DocValue('page_views') FROM index;

Thanks for the info! So what kind of ES DSL you expect to generate from the query you proposed? If this only concerns performance, ideally I think our query engine should take care of the performance behind the scene.