Skip to main content
QUICK REVIEW

[논문 리뷰] GenRewrite: Query Rewriting via Large Language Models

Jie Liu, Barzan Mozafari|arXiv (Cornell University)|2024. 03. 14.
Data Quality and Management인용 수 5
한 줄 요약

GenRewrite는 자연어 재작성 규칙(NLR2s)과 반례 가이드 루프를 갖춘 대형 언어 모델(LLMs)을 이용해 성능 향상을 위한 SQL 쿼리를 재작성하는 포괄적 시스템을 도입하며, TPC 벤치마크에서 상당한 커버리지와 속도 향상을 달성합니다.

ABSTRACT

Query rewriting is an effective technique for refining poorly written queries before they reach the query optimizer. However, manual rewriting is not scalable, as it is prone to errors and requires deep expertise. Traditional query rewriting algorithms fall short too: rule-based approaches fail to generalize to new query patterns, while synthesis-based methods struggle with complex queries. Fortunately, Large Language Models (LLMs) already possess broad knowledge and advanced reasoning capabilities, making them a promising solution for tackling these longstanding challenges. In this paper, we present GenRewrite, the first holistic system that leverages LLMs for query rewriting beyond traditional rules. We introduce the notion of Natural Language Rewrite Rules (NLR2s), which serve as hints for the LLM while also a means of knowledge transfer from rewriting one query to another, allowing GenRewrite to become smarter and more effective over time. We present a novel counterexample-guided technique that iteratively corrects the syntactic and semantic errors in the rewritten query, significantly reducing the LLM costs and the manual effort required for verification. Across the standard TPC-DS and JOB benchmarks and their SQLStorm-generated variants, GenRewrite consistently optimizes more queries at every speedup threshold than all baselines. At the >=2x threshold on TPC-DS, GenRewrite improves 25 queries-1.35x more than LLM-driven baselines and 2.6x more than LLM-enhanced rule-based baselines-and the gap widens further on TPC-DS (SQLStorm); on JOB and its SQLStorm variant, where queries are simpler, absolute gains are smaller but GenRewrite still leads by a notable margin.

연구 동기 및 목표

  • 확장 가능한 자동 쿼리 재작성의 필요성에 대해 패턴 기반 규칙과 수동 노력 너머의 필요성 제시.
  • LLMs와 자연어 재작성 규칙(NLR2s)을 활용하여 생성, 수정, 평가를 수행하는 포괄적 GenRewrite 시스템 제안.
  • 재작성의 구문 및 의미적 오류를 수정하기 위한 반례 가이드 반복 보정 방법 도입.
  • NLR2 저장소와 유용도 점수를 통해 쿼리 간 지식 공유를 가능하게 하고 힌트 우선순위를 정합니다.

제안 방법

  • 자연어 재작성 규칙(NLR2s)을 LLM이 생성한 사람 읽기 쉬운 힌트로 정의하여 재작성 가이드를 제공하고 지식 전달을 가능하게 합니다.
  • NLR2 저장소를 유지하고 유용도 점수를 사용하여 주어진 쿼리에 대해 관련 힌트만 선택합니다.
  • 세 단계 루프를 적용합니다: 재작성 제안, 동등성에 대한 수정, 동등성 및 성능에 대한 평가.
  • 피드백에 기반해 재작성의 구문/의미적 오류를 반례 가이드를 통해 반복적으로 수정합니다.
  • 실제 실행이나 데이터베이스 비용 모델을 통해 성능을 추정하고 NLR2 유Utility를 업데이트합니다.
  • 쿼리당 30초의 시간 예산(또는 사용자 지정)을 두고 재발작 로드를 최적화합니다.

실험 결과

연구 질문

  • RQ1LLMs를 전통적인 규칙 기반 또는 합성 기반 접근 방식 너머의 쿼리 재작성에 효과적으로 활용할 수 있을까?
  • RQ2쿼리 간 지식 공유를 통해 커버리지를 시간이 지나면서 개선할 수 있을까?
  • RQ3반례 가이드를 통한 반복적 보정이 재작성의 부정확한 부분과 LLM 비용을 줄이면서 동등성과 속도향상을 유지할 수 있을까?
  • RQ4NLR2-가이드 힌트가 복잡한 벤치마크(TPC-DS)에서 재작성 품질과 전반적 성능에 어떤 영향을 미칠까?

주요 결과

  • GenRewrite는 99개 중 22개의 TPC-DS 쿼리를 재작성하여 2배 이상 속도 향상을 달성합니다.
  • 이 접근은 최첨단 전통적 재작성 대비 2.5배–3.2배의 더 높은 커버리지를 제공하고, 기본 제공 LLM 성능 대비 2.1배 더 높습니다.
  • NLR2는 지식 전달과 더 나은 힌트 선택을 가능하게 하여 LLM에 불필요하거나 충돌하는 지침을 줄입니다.
  • 반례 가이드 기술은 재작성 쿼리의 의미적 및 구문적 오류를 크게 줄입니다.
  • 시스템은 재작성의 확인 및 이해를 돕기 위한 재작성의 인간 읽기 가능한 설명을 강조합니다.
  • GenRewrite의 프레임워크는 일반적이고 스키마에 독립적인 NLR2에 초점을 맞춤으로써 워크로드 간 재작성 재사용을 지원합니다.

더 나은 연구,지금 바로 시작하세요

연구 설계부터 논문 작성까지, 연구 시간을 획기적으로 줄여보세요.

카드 등록 없음 · 무료 플랜 제공

이 리뷰는 AI가 만들고, 인간 에디터가 검토했습니다.