holistic optimization of database applications · the problem •applications invoke db queries/web...

1
The Problem Applications invoke DB queries/Web Service requests repeatedly (with different parameters) synchronously (blocking on every request) Naive iterative execution of such queries: inefficient No sharing of work (eg. Disk IO) Network round-trip delays Soln 1: Batching Repeated invocation of a query automatically replaced by a single invocation of its batched form Enables use of efficient set-oriented query execution plans Query optimization: time to think out of the box! Soln 2: Asynchronous Submission Repeated synchronous invocation of queries automatically replaced by asynchronous submission Application can perform other work while query executes Multiple queries could be issued concurrently Approach Analyze application programs along with embedded queries Transform programs using equivalence rules and semantics preserving reordering Rewrite queries using decorrelation, APPLY operator, etc. DBridge: Implementation for Java/JDBC, using Soot framework (http://www.cse.iitb.ac.in/dbms/dbridge) Performance gains (upto 7x)! Program Transformation Identical API for Batching and Asynchronous approach Asynchronous mode Batching mode Holistic Optimization of Database Applications Karthik Ramachandra, IIT Bombay with R Guravannavar (IIT Hyderabad), M Chavan & S Sudarshan (IIT Bombay) Submit Q Parameter Batch (temp table) Set of ResultSets LoopContextTable lct = new LoopContextTable(); while(category != null){ LoopContext ctx = lct.createContext(); stmt.setInt(1, category); ctx.setInt(”category”, category); category = getParent(category); stmt.addBatch(ctx); } for (LoopContext ctx : lct) { category = ctx.getInt(”category”); ResultSet rs = stmt.getResultSet(ctx); int count = rs.getInt(”count"); sum += count; print(category + ”: ” + count); } Threads DB Array of ResultSets Output program after Loop Splitting Query rewrite DB Reorder Split Loop Build/ Update DDG Decompile Data flow analysis Parsing while (category != null) { qt.setInt(1, category); int count = qt.executeQuery (); sum = sum + count; category=getParent(category); } S1: S2: S3: S4: S1: S2: S3: S4: S5: Input program Reordered program before Loop Splitting Experiment 1: DB Query invocation (Auction System Benchmark) Experiment 2: Web Service invocation (Batching not possible here as there is no set-oriented interface exposed by the web service) The Problem is not within the database engine in the way queries are invoked from the application S1 S2 S3 S4

Upload: others

Post on 29-Sep-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Holistic Optimization of Database Applications · The Problem •Applications invoke DB queries/Web Service requests •repeatedly (with different parameters) •synchronously (blocking

The Problem

• Applications invoke DB queries/Web Service requests

• repeatedly (with different parameters)

• synchronously (blocking on every request)

• Naive iterative execution of such queries: inefficient

• No sharing of work (eg. Disk IO)

• Network round-trip delays

Soln 1: Batching

•Repeated invocation of a query automatically

replaced by a single invocation of its batched form

•Enables use of efficient set-oriented query

execution plans

Query optimization: time to think out of the box!

Soln 2: Asynchronous Submission

•Repeated synchronous invocation of queries

automatically replaced by asynchronous submission

•Application can perform other work while query executes

•Multiple queries could be issued concurrently

Approach

•Analyze application programs along with embedded queries

•Transform programs using equivalence rules and semantics preserving reordering

•Rewrite queries using decorrelation, APPLY operator, etc.

•DBridge: Implementation for Java/JDBC, using Soot framework (http://www.cse.iitb.ac.in/dbms/dbridge)

Performance gains (upto 7x)! Program Transformation

Identical API for Batching and Asynchronous approach

Asynchronous mode Batching mode

Holistic Optimization of Database

Applications

Karthik Ramachandra, IIT Bombay with R Guravannavar (IIT Hyderabad), M Chavan & S Sudarshan (IIT Bombay)

Submit Q

Parameter Batch

(temp table)

Set of ResultSets

LoopContextTable lct = new LoopContextTable();

while(category != null){ LoopContext ctx = lct.createContext(); stmt.setInt(1, category); ctx.setInt(”category”, category); category = getParent(category);

stmt.addBatch(ctx); } stmt.executeBatch(); for (LoopContext ctx : lct) {

category = ctx.getInt(”category”); ResultSet rs = stmt.getResultSet(ctx); int count = rs.getInt(”count"); sum += count; print(category + ”: ” + count);

}

Threads

DB

Array of ResultSets

Output program after Loop Splitting

Query

rewrite

DB

Reorder

Split Loop

Build/ Update

DDG Decompile Data flow analysis

Parsing

while (category != null) {

qt.setInt(1, category);

int count = qt.executeQuery();

sum = sum + count;

category=getParent(category);

}

S1:

S2:

S3:

S4:

while (category != null) {

int temp = category;

category = getParent(category);

qt.setInt(1, temp);

int count = qt.executeQuery();

sum = sum + count;

}

S1:

S2:

S3:

S4:

S5:

Input program Reordered program before Loop Splitting

Experiment 1: DB Query invocation (Auction System Benchmark)

Experiment 2: Web Service invocation

(Batching not possible here as there is no set-oriented

interface exposed by the web service)

The Problem is not within the database engine

in the way queries are invoked

from the application

S1

S2

S3

S4