Article Complete
    AIM

    Alibaba Launches LLM-R2 to Optimise SQL Query Efficiency

    Alibaba Launches LLM-R2 to Optimise SQL Query Efficiency

    Discover how Alibaba's LLM-R2 optimizes SQL queries for faster execution. Learn more about this innovative technology today!

    Alibaba Launches LLM-R2 to Optimise SQL Query Efficiency
    Sukriti GuptaΒ·
    5 min

    Researchers at Nanyang Technological University, Singapore University of Technology and Design, and Alibaba's DAMO Academy recently introduced LLM-R2, a rule-based query rewrite system enhanced with an LLM, to significantly boost SQL query efficiency.

    The core objective of query rewrite is to transform an SQL query into a new format that maintains the original results while executing more efficiently. This involves three key criteria: executability, equivalence, and efficiency. Traditional query rewrite systems heavily rely on predefined rules and are often constrained by the computational limitations and inaccuracies of DBMS cost estimators. 

    LLM-R2 addresses these challenges by integrating a LLM to suggest optimal rewrite rules for SQL queries, which are then implemented using an existing database platform. This allows the rewritten queries to maintain their executability and accuracy while improving efficiency.

    One of the key advancements of LLM-R2 is its use of contrastive learning models that help in refining the selection of rewrite rules by understanding the structure and context of each query. This allows LLM-R2 to adapt and apply the most appropriate optimizations, leading to a significant reduction in query execution times across various datasets.

    This method has proven to significantly cut down query execution times across various datasets including TPC-H, IMDB, and DSB, demonstrating improvements over both traditional rule-based methods and other LLM-based systems.

    The results show that LLM-R2 can reduce the execution time of SQL queries to about 52.5% on average compared to original queries, and about 40.7% compared to state-of-the-art methods. This performance boost is especially pronounced in complex queries where the traditional methods often struggle to make effective improvements.

    The research acknowledges that its main limitation lies in the higher rewrite latency compared to DB only methods. Because, compared to traditional DB methods, calling LLM API and selecting demonstrations consumes more time.

    Despite this delay, the benefits are clear, LLM-R2 greatly reduces the time it takes to execute queries, making the system overall very effective. This shows that LLM-enhanced methods could be an effective solution for efficiency-oriented query rewrite.

    Your reaction

    Discussion

    What's your take on this story?

    0/1000

    No comments yet β€” be the first to share your view.

    Explore our newsletters

    Build your routine with some of our top newsletters or view them all here.

    Wake up informed

    Make sense of the day's AI news and breakthroughs with our morning briefing.

    Belamy
    WeeklyBelamySee the latest

    Industry intelligence

    Receive a roundup of AI adoption stories by industry vertical, curated for professionals.

    3x WeeklySector6See the latest

    By signing up, you agree to our Privacy Policy.

    Membership

    Stay ahead with AI insights.

    Unlimited access to premium articles, exclusive analysis, and the stories shaping India's AI economy.

    Subscribe now

    AIM Americas

    1190 Miraloma Way Suite P, Sunnyvale, CA 94085

    AIM India

    1st Floor, Sakti Statesman, Bellandur, Bengaluru – 560103

    Β© 2026 AIM. All rights reserved.