8
Meta-SQL: Towards practical meta-querying Jan Van den Bussche Stijn Vansummeren Limburgs Universitair Centrum Gottfried Vossen University of Muenster

Meta-SQL: Towards practical meta-querying

Embed Size (px)

DESCRIPTION

Meta-SQL: Towards practical meta-querying. Gottfried Vossen University of Muenster. Jan Van den Bussche Stijn Vansummeren Limburgs Universitair Centrum. Context. Enterprise databases contain not only data but also queries: view definitions stored procedures usage logs workloads - PowerPoint PPT Presentation

Citation preview

Page 1: Meta-SQL: Towards practical meta-querying

Meta-SQL: Towards practical meta-querying

Jan Van den BusscheStijn Vansummeren

Limburgs Universitair Centrum

Gottfried Vossen

University of Muenster

Page 2: Meta-SQL: Towards practical meta-querying

Context

Enterprise databases contain not only data but also queries:

• view definitions• stored procedures• usage logs• workloads• software engineering

Stored as long strings… Difficult to query in standard SQL

Page 3: Meta-SQL: Towards practical meta-querying

Goal

Allow meta-querying: query the stored queries together with ordinary data

• Which queries do the most joins?• Which queries return an empty answer?• What are common subexpressions in this workload?• If I do these updates, which materialized views change their value?

Page 4: Meta-SQL: Towards practical meta-querying

Contribution

Meta-SQL: conservative extension of SQL to allow meta-querying

• store queries in XML• call XSLT within SQL• add XML-variables• add an EVAL function

Works on top of any SQL99-compliant DBMS

Prototype with DB2 UDB

Page 5: Meta-SQL: Towards practical meta-querying

Call XSLT within SQL

Which queries do the most joins?

select name from Views where count_tables(def) =(select max( ( )) from Views)

written in XSLT view definition in XML

count_tables def

Page 6: Meta-SQL: Towards practical meta-querying

XML-variables

select s from Views, s in def[ ]group by shaving count(name)>=2

s ranges over all query-subelements of stored query

arbitrary Xpath-expression

//query

What are the common subqueries?

Page 7: Meta-SQL: Towards practical meta-querying

EVAL function

select name from Views where not exists(select * from EVAL(def))

Which queries return an empty answer?

EVAL produces query results in SQL row variableUEVAL produces them in XML-variable

Page 8: Meta-SQL: Towards practical meta-querying

Implementation

XSLT functions Meta-SQL query

Java wrappersSQL statements(CREATE FUNCTION)

Rewriting in SQL99

SAXON (XML processing) Extract (XML variables)EVAL

compilation

execution