DAMO-NLP-SG / LLM-R2

30 stars 2 forks source link

How to Determine Whether an Input SQL Query Needs Optimization? What Happens to SQL Queries That Do Not Require Optimization? #1

Closed koalasix-sky closed 2 days ago

koalasix-sky commented 3 weeks ago

Thank you for open-sourcing the impressive work of LLM-R2. However, in practice, not all SQL queries need optimization. Does our architecture include a component to determine "whether optimization is needed" for SQL queries? What would happen if an SQL query that doesn't require optimization is inputted?

Looking forward to your reply.

LZ12DH commented 2 weeks ago

Thanks for the question! In practice we rely on both the LLM itself and our demonstration selection to deal with optimal input queries.

Firstly, in our demonstration pool, we have demonstrations that are optimal queries where no rewrite rules are applied to these demonstration queries. (in practice we align their outputs to be 'empty rule' for LLM to better understand) So when a potentially optimal query is given, the demonstration selected will highly likely to be an optimal demonstration without rewrite. In our experiments, many queries, especially from the easiest JOB workload, are already optimal and we manage not to rewrite them.

Secondly, we find that even in the zero-shot stage, LLM is able to identify some of the optimal queries and choose not to give additional rewrite rules. So this will be an insurance for the method to not rewrite optimal queries.

Thanks again for your interest and we hope this reply clarifies your doubts!