Conference PaperPDF Available

Stethoscope: A Platform for Interactive Visual Analysis of Query Execution Plans

Authors:

Abstract and Figures

Searching for the performance bottleneck in an execution trace is an error prone and time consuming activity. Ex-isting tools offer some comfort by providing a visual repre-sentation of trace for analysis. In this paper we present the Stethoscope, an interactive visual tool to inspect and ana-lyze columnar database query performance, both online and offline. It's unique interactive animated interface capitalizes the large data-flow graph representation of a query execution plan, augmented with query execution trace information. We demonstrate features of Stethoscope for both online and offline analysis of long running queries. It helps in under-standing where time goes, how optimizers perform, and how parallel processing on multi-core systems is exploited.
Content may be subject to copyright.
Stethoscope: A Platform for Interactive Visual Analysis of
Query Execution Plans
Mrunal Gawade
CWI, Amsterdam
mrunal.gawade@cwi.nl
Martin Kersten
CWI, Amsterdam
martin.kersten@cwi.nl
ABSTRACT
Searching for the performance bottleneck in an execution
trace is an error prone and time consuming activity. Ex-
isting tools offer some comfort by providing a visual repre-
sentation of trace for analysis. In this paper we present the
Stethoscope, an interactive visual tool to inspect and ana-
lyze columnar database query performance, both online and
offline. It’s unique interactive animated interface capitalizes
the large data-flow graph representation of a query execution
plan, augmented with query execution trace information.
We demonstrate features of Stethoscope for both online and
offline analysis of long running queries. It helps in under-
standing where time goes, how optimizers perform, and how
parallel processing on multi-core systems is exploited.
1. INTRODUCTION
Understanding database query execution traces is one of
the most complex issues in database system research. Their
analysis is needed to understand and to achieve optimal per-
formance. Different implementations of database systems
use different query representation formats. Queries vary in
their complexity and so do their plans.
A query execution trace is a good starting point to reflect
upon the run-time behavior. In offline mode, the execution
steps taken can be inspected in detail for unanticipated be-
havior. In online mode, it can provide insight in the total
system behavior. For example, influence of concurrent pro-
cesses competing with the resources. Performance analysis
tools are often specific to the DBMS, however the funda-
mental techniques used could be utilized, in the design of
new tools.
In this demo, we present Stethoscope, a platform to anal-
yse MonetDB [3] query plans and their execution traces.
Each query plan models a dataflow dependency, which al-
lows it to be represented as a directed acyclic graph (DAG),
described in a dot file. Stethoscope combines dot file and
execution trace to build a powerful tool, which animates the
execution trace and provides navigational access to the por-
tions of interest in the plan. This way, it can be used to
monitor long running queries and performance bottlenecks
in the kernel. Stethoscope provides the following features:
1. Interactive animated navigation in complex query plans.
2. Color coded monitoring of query execution state changes.
3. Run time analysis of execution states using debug window,
tool tip text.
4. Flexible options for filtering of execution traces.
5. Support for large query plans with graph representation
of more than 1000 nodes.
The interactive animated features by Stethoscope makes
analysis more interesting and less error prone, as compared
to other tools, which rely on manual browsing methods, in
a static graphical representation of an execution trace. In
the remainder of the paper, we provide a brief overview of
the Stethoscope architecture, demonstration guidelines, and
lessons learned during its implementation.
2. BACKGROUND
MonetDB is an open-source columnar database system
developed at CWI [3]. It is predominantly used for OLAP
based workloads. One of the prime features of MonetDB
is its ability to support multiple front end data models,
including query language interfaces such as SQL, SciQL,
JSON/JAQL, and XQuery, etc. Client connections could
be also made through PHP, JDBC, and ODBC interfaces.
MonetDB uses the MonetDB Assembly Language (MAL),
as an intermediate language to represent query plans. For
example, a SQL query gets parsed and is converted into a re-
lational algebra representation. This algebra representation
is then converted to a MAL plan. Subsequently, optimizers
work on the generated MAL plan to derive an optimized
MAL plan. The final MAL plan is then interpreted. Figure
1 displays a MAL plan for the SQL query described next,
from a TPC-H schema [6]. A graph representing complex
MAL plan could grow very large in size. Figure 2 displays
such a graph.
select l tax from lineitem where l partkey=1.
The plan is a sequence of semantically arranged MAL in-
structions. The literals starting with “X ” are MAL vari-
ables. MAL variables are assigned return values of MAL
statements [9]. A MAL statement has a syntax of the form
“module.function(variable1,variable2,...)”. For example, in
the statement “algebra.leftjoin(X 23,X 10)”, “leftjoin” is a
function in the “algebra” module. MAL comprises of a set
of modules and a set of functions supported by each module.
MonetDB provides a GDB-like MAL debugger for runtime
1926
Permission to make digital or hard copies of all or part of this work for
personal or classroom use is granted without fee provided that copies are
not made or distributed for profit or commercial advantage and that copies
bear this notice and the full citation on the first page. To copy otherwise, to
republish, to post on servers or to redistribute to lists, requires prior specific
permission and/or a fee. Articles from this volume were invited to present
their results at The 38th International Conference on Very Large Data Bases,
August 27th - 31st 2012, Istanbul, Turkey.
Proceedings of the VLDB Endowment, Vol. 5, No. 12
Copyright 2012 VLDB Endowment 2150-8097/12/08... $10.00.
Figure 1: MAL plan for a simple SQL query
inspection. However, further improvements could be gained
by having a visual assistance tool that analyzes MAL exe-
cution traces. Stethoscope helps here by providing a set of
functionalities to analyze MAL plans, in a fast and efficient
manner.
3. SYSTEM ARCHITECTURE
The Stethoscope is a Java application and integrates open-
source products such as the the MonetDB profiler [3], Graph-
Viz library [4], and ZGrviewer component [7] of ZVTM tool-
set [8]. We describe each of these tools here.
Mserver is the MonetDB database server [3]. It is the main
component which encapsulates the entire MonetDB execu-
tion environment. Mserver works as a background process.
It listens for the incoming client connections on user defined
ports. Stethoscope connects to Mserver as a client.
The MAL profiler is a component in MonetDB kernel
which profiles executed MAL instructions. It supports pro-
filing of events using several OS-specific properties, such as
IO behavior, memory usage and cpu state, and MAL state-
ment state. The profiler accepts filter options set through
Stethoscope, which enables it to profile only a subset of event
types. The events are either sent over a UDP stream back to
the Stethoscope, or are dumped in a file, for offline analysis.
The MonetDB server generates a dot file representation
for each MAL plan before execution begins. A dot file repre-
sents a graph and describes the grammar for the representa-
tion of nodes, and the association between nodes and edges
[2]. GraphViz can convert a dot file to a graph structure
representation [4]. Stethoscope uses this graph structure
representation to setup different navigational strategies.
3.1 ZGrviewer
ZGrviewer is an open source tool from the ZVTM tool
set which provides interactive navigation functionality in
a graph structure [7]. The highlight of ZGrviewer is the
zoom-able interface which allows keyboard and mouse scroll
based navigation with zooming ability on individual nodes
and edges in a graph. ZGrviewer comes with a plethora of
features such as set of lenses viz. fish eye lens, etc. for visual
interaction with graph nodes. ZGrviewer is implemented
in Java and the Stethoscope uses ZGrviewer interfaces for
interactive navigation in the graph structure. The Stetho-
scope code integrates with the ZGrviewer code base in a
modular manner and provides interfaces for extensibility.
ZGrviewer stores graphics related meta-information in mul-
tiple structured object representations. Glyph is a structure
Figure 2: Large graph for a complex SQL query
representing a fundamental graphical object in ZGrviewer
[1]. For example, consider a two node graph, with one undi-
rected edge between them. Assume each node is represented
with the shape of a circle and has a text label associated
with it. ZGrviewer uses a glyph object each, to represent
the shape, text, and edge. Thus for our example graph,
ZGrviewer maintains following objects, shape (two objects),
text (two objects), and edge (one object). Other important
objects are a virtual space, which represents a canvas on
which graphs are dawn and a camera object, which shows
different views at different zoom levels, in a virtual space.
3.2 Textual Stethoscope
The MonetDB profiler information is accessed through a
textual version of Stethoscope. It uses a UDP socket inter-
face to connect to MonetDB server, for receiving the Mon-
etDB execution trace. The textual Stethoscope can connect
to multiple MonetDB servers at the same time to receive
execution traces from all (distributed) sources. Its filter op-
tions allow for selective tracing of execution states on each
of the connected servers. The profiler intercepted events on
these servers are streamed back on a UDP connection to the
textual Stethoscope. A sample execution trace from a trace
file looks as given in the Figure 3.
3.3 Trace and Dot File Mapping
Each MAL instruction is represented in the trace in the
Figure 3, with two events. A “start” event marks the start
of the instruction and a “done” event marks the end of the
instruction. The program counter (pc) is an important field
in the trace, and is used to map pc to a node number in a
dot file. For example, an instruction execution trace state-
ment with pc=1 maps to the node “n1” in the dot file. The
“stmt” field in instruction execution trace represents a MAL
instruction and maps to the “label” field in the dot file.
4. WORK-FLOW DESCRIPTION
The Stethoscope works in both online and offline mode.
Both modes share some fundamental steps, such as dot file
parsing, conversion to an in memory graph representation,
and sequential reading of a trace file. As a first step the
dot file gets parsed and an intermediate scalar vector graph-
ics (svg) representation gets created. In the next step, the
svg file gets parsed and an in memory graph structure gets
created. The root node of this graph structure is used to tra-
verse the graph at a later stage. Both steps use the Graphviz
library interface. As a next step, Stethoscope parses the
trace file in a sequential manner, storing attributes of the
trace file. The “event” attribute from the trace is used as
1927
Figure 3: MAL plan execution trace of a simple SQL query
an index to store the attribute contents. The “pc” attribute
is mapped to a node name, to search for the corresponding
node in the graph structure, during graph traversal.
4.1 Offline
The system uses event based programming interfaces to
monitor click events and takes appropriate action in re-
sponse. Prominent actions are navigate to the next node
in the graph, change color of a node, and display tool-tip
text. We describe the features related to these actions in
the demonstration section. Offline mode needs access to a
preexisting dot file and trace file. Once the off-line mode is
selected, and the initial dot file parsing to graph structure
creation stage is over, interactive analysis begins.
4.2 Online
In online mode, both dot and trace files are generated
at run-time by MonetDB server. Online mode components
use a multi-threaded design. As a first step, the textual
Stethoscope is launched in a dedicated thread. The textual
Stethoscope awaits in a listening mode for the arrival of trace
stream on UDP connection. The trace received is redirected
to a trace file.
The query whose execution plan needs to be analyzed is
launched next in a separate thread. The trace file continu-
ously receives the trace stream from the textual Stethoscope,
while the query execution is in progress.
The dot file is a prerequisite for the graph structure gen-
eration. The MonetDB server generates the dot file content
and sends it over on the UDP stream to the textual Stetho-
scope, before query execution begins. A separate thread
monitors the received UDP stream for dot file and execution
trace file content. It filters the dot file content, generates a
new dot file, and stores the content in it.
As the query execution begins, MonetDB profiler gener-
ates MAL instruction execution trace and sends to the tex-
tual Stethoscope. The monitoring thread filters the trace
and a trace file is generated. As the trace file grows in size,
its content is sampled in a buffer. MonetDB query plans
have instructions where MAL operator takes long time to
execute, for example a join operator. When this occurs, the
execution trace blocks, resulting in blocking of the growth
of trace file. An algorithm for run-time analysis, to filter
lengthy MAL instructions is applied on the buffer content.
We describe this algorithm in brief, in Section 4.2.1.
4.2.1 Run-time Analysis
Finding long running instructions in a MAL plan is one of
the main purpose of the Stethoscope. Lengthy instructions
could be filtered either on server or client side. They could
be represented by color coding, progress window, and pop-
ups. We focus on coloring of nodes to represent state change,
on the client side.
Coloring graph nodes in an online stream is a complex
task due to rendering limitations from the Java system. The
Stethoscope uses the Java Event Dispatch thread queuing
framework for queuing up nodes to render. This introduces
a delay of up-to 150ms between rendering of consecutive
nodes. A node is colored RED or GREEN based on the
instruction status of “start” or “done” respectively.
Most instructions in the execution trace occur in sequence
of pairs of “start” and “done” events. A consecutive “start”
and “done” event status for the same instruction, with pres-
ence of more instructions afterwards, indicates that the in-
struction under analysis executed in least time. Hence, it is
not a costly instruction. All such instructions are not col-
ored. An instruction which does not appear in a sequence
of pairs of “start” and “done” event is colored. For exam-
ple, consider a pruned execution trace buffer from Figure
3, with fields {status,pc}, representing 6 instruction state-
ments {start,1},{done,1},{start,2},{done,2},{start,3},{start,
4}. The graph nodes corresponding to first four statements
will not be colored, as the two instructions corresponding
to pc=1 and pc=2 occur in a pair, in a sequence. However,
1928
Figure 4: Display window for a simple MAL plan execution trace analysis
the graph node corresponding to the fifth instruction with
pc=3 will be colored in RED. Hence, this graph node color-
ing algorithm doesn’t check a specific instruction execution
threshold time. We provide another algorithm which allows
the user to specify an instruction execution threshold time.
5. DEMONSTRATION
The focus of the demonstration would be to exhibit var-
ious features of Stethoscope, while analyzing long running
TPC-H queries in both online and offline mode.
Offline Demo: We use the trace replay feature to show uti-
lization distribution of threads, memory usage by operators,
and costly instruction clustering. A user can play with the
following features, to analyze MAL plan execution trace.
Step by step walk through, monitoring individual in-
struction using Stethoscope filter options window, de-
bug options window, and tool-tip text display.
Fast-forward, rewind, and pause functionality of the
trace replay.
Finding costly instructions by coloring during trace
replay between two instruction states.
Birds eye view of the entire trace, to understand the
sequence of instruction execution clustering.
Animation effects such as change of zoom level, color,
and transition time between highlights of nodes.
Online Demo: Online mode exhibits similarity to the of-
fline trace replay feature. Multi-core utilization analysis ex-
hibits degree of multi-threaded parallelization of MAL in-
structions and interference from rest of the load on the sys-
tem. Some other ways to analyze MAL plan execution are
as follows.
Monitor the progress of query plan execution, and
highlight long running instructions based on the al-
gorithm described in Section 4.2.1.
Analyze runtime resource utilization by long running
instructions using multiple instances of debug options
window, and tool tip text display.
To illustrate, using Stethoscope we have uncovered several
unusual cases, such as sequential execution of a MAL plan
where multithreaded execution was expected.
6. CONCLUSION
Stethoscope is an extensible platform for query execution
analysis in columnar systems such as MonetDB. The main
contribution is a unique interactive animated interface for
analysis of execution trace and the role it plays to gain
performance insight. Developing an interactive visual front
end platform using open-source tools has been a challenging
task. We spent considerable time in understanding the code
base of ZGrviewer, and experimenting to find the correct
logic for coloring of individual graph objects, in online and
offline mode. Rendering of nodes in tune with the online
trace flow is a challenge, due to refresh rate limitations of
the system. User interface and event based programming in
general involves tedious manual testing approach.
We have the following features planned for a future release
of the stethoscope. An analytic interface for micro analysis
of trace, gradient coloring of graph nodes to display a range
of execution times, and selective pruning of MAL plan to
remove unimportant administrative instructions.
7. REFERENCES
[1] E. Pietriga. A toolkit for addressing HCI issues in
visual language environments. In VLHCC,145-152,2005.
[2] Drawing graphs with dot.
http://www.graphviz.org/Documentation/dotguide.pdf
[3] MonetDB, www.monetdb.org.
[4] GraphViz, www.graphviz.org.
[5] DOT, www.graphviz.org/doc/info/lang.html.
[6] TPC-H Benchmark, www.tpc.org/tpch.
[7] ZGrviewer, www.zvtm.sourceforge.net/zgrviewer.html.
[8] ZVTM, www.zvtm.sourceforge.net.
[9] MAL, www.monetdb.org/Documentation/Manuals/
MonetDB/MALreference.
1929
... QE3D [11] is another query plan visualization tool that provides holistic view of distributed query plans executed by the SAP HANA database management system. Stethoscope [2] is an interactive visual tool to analyze plans for a columnar database. However, to the best of our knowledge, there has been no prior work on natural language understanding of query plans. ...
Preprint
Full-text available
Natural language interfaces for relational databases have been explored for several decades. Majority of the work have focused on translating natural language sentences to SQL queries or narrating SQL queries in natural language. Scant attention has been paid for natural language understanding of query execution plans (QEP) of SQL queries. In this demonstration, we present a novel generic system called NEURON that facilitates natural language interaction with QEPs. NEURON accepts a SQL query (which may include joins, aggregation, nesting, among other things) as input, executes it, and generates a natural language-based description (both in text and voice form) of the execution strategy deployed by the underlying RDBMS. Furthermore, it facilitates understanding of various features related to the QEP through a natural language-based question answering framework. NEURON can be potentially useful to database application developers in comprehending query execution strategies and to database instructors and students for pedagogical support.
... Rectangles represent operators, and edges between them represent the dependencies. The graph is only meant to give a high level perspective of the plan's complexity, abstracting individual operator details. [12] shows graphs where operators are visible. ...
... We used MonetDB's Tomograph [26] and Stethoscope [27], as well as standard Unix tools to view and measure parallelism and overall execution times. Both Stethoscope and Tomograph provide per-operation execution times-with Stetho- scope providing even more fine-grained details. ...
... We used MonetDB's Tomograph [26] and Stethoscope [27], as well as standard Unix tools to view and measure parallelism and overall execution times. Both Stethoscope and Tomograph provide per-operation execution times-with Stetho- ...
Conference Paper
Full-text available
Contemporary DBMS systems already use data-partitioning and data-flow analysis for intra-query parallelism. We study the problem of identifying data-partitioning targets. To rank candidates, we propose a simple cost model that relies on plan structure, operator cost and selectivity for a given base table. We evaluate this model in various optimization schemes and observe how it affects degrees of parallelism and query execution latencies across all TPC-H queries: When compared with the existing nave model which partitions the largest physical table in the query, our approach identifies significantly better partitioning targets thus resulting in sinificantly higher degree of resource utilization and intra-query parallelism for most queries while having little impact on the remaining queries in the TPC-H benchmark.
... Postgres uses similar tools [20]. MonetDB uses a tool called stethoscope, to visualize a data flow dependency graph of a query plan [21]. Vtune analyzer from Intel is used for profiling program execution using a similar visualization scheme as Tomograph [22]. ...
Conference Paper
Full-text available
Query parallelism improves serial query execution performance by orders of magnitude. Getting optimal performance from an already parallelized query plan is however difficult due to its dependency on run time factors such as correct operator scheduling, memory pressure, disk io performance, and operating system noise. Identifying the exact problems in a parallel query execution is difficult due to inter-dependence of these factors. In this paper we present Tomograph, a tool to visualize the parallel query execution performance bottlenecks. Tomograph provides a time ordered view of operator execution aligned with cpu, memory, and disk IO usage, in an operator at a time execution model. We discuss the usage of Tomograph to identify parallelism issues such as low multi-core utilization, erroneous operator scheduling, incorrect data partitioning, and blocking operators. We share our experiences, insights gained and discuss possible solutions to the identified problems.
Article
Full-text available
The database systems course has gained increasing prominence in academic institutions due to the convergence of widespread usage of relational database management system (RDBMS) in the commercial world, the growth of Data Science, and the increasing importance of lifelong learning. A key learning goal of learners taking such a course is to learn how SQL queries are processed in an RDBMS in practice. Most database courses supplement traditional modes of teaching with technologies such as off-the-shelf RDBMS to provide hands-on opportunities to learn database concepts used in practice. Unfortunately, these systems are not designed for effective and efficient pedagogical support for the topic of relational query processing. In this vision paper, we identify novel problems and challenges that need to be addressed in order to provide effective and efficient technological supports for learning this topic. We also identify opportunities for data-driven education brought by any effective solutions to these problems. Lastly, we briefly report the TRUSS system that we are currently building to address these challenges.
Chapter
Triple Pattern Fragments (TPFs) allow for querying large RDF graphs with high availability by offering triple pattern-based access to the graphs. The limited expressivity of TPFs leads to higher client-side querying and communication costs with potentially many intermediate results that need to be transferred. Thus, the challenge of devising efficient query plans when evaluating SPARQL queries lies in minimizing these costs. Different heuristics and cost-based query planning approaches have been proposed to obtain such efficient query plans. However, we also require means to visualize, manually modify, and execute alternative query plans, to better understand the differences between existing planning approaches and their potential limitations. To this end, we propose Slurp (https://people.aifb.kit.edu/zg2916/slurp/), an interactive SPARQL query planner that assists RDF data consumers to visualize, modify, and compare the performance of different query execution plans over TPFs.
Conference Paper
QE3D is a novel query plan visualization tool that aims at providing an intuitive and holistic view of distributed query plans executed by the SAP HANA database management system. In this demonstration, we show how its interactive, three-dimensional plan representation helps to understand and quickly identify hotspots in complex, real-world scenarios.
Article
Today's hardware architectures provide an ever-increasing number of CPU cores that can be used for running concurrent operations. A big challenge is to ensure that these operations are properly synchronized and make efficient use of the available resources. Fellow database researchers have appropriately described this problem as "staring into the abyss" of complexity [12], where reasoning about the interplay of jobs on a thousand cores becomes extremely challenging. In this demonstration, we show how a new tool, JexLog, can help to visually analyze concurrent jobs in system software and how it is used to optimize for modern hardware.
Article
Database query monitoring tools collect performance metrics, such as memory and cpu usage, while a query is executing and make them available through log files or system tables. The metrics can be used to understand and diagnose query performance issues. However, analytic queries over big data presents new challenges for query monitoring tools. A long-running query may generate tens of thousands of values so simply reporting the metrics may overwhelm the user. Second, analytic queries may be written by database novices who have trouble interpreting the metrics. Third, analytic queries may access data or processing outside the database through user-defined functions and connectors. The impact of these on query performance must be understood. Vertica Query Analyzer (VQA) is a query monitoring tool to address these challenges. VQA is both a useful tool and a research platform for query analytics. It presents query performance metrics through a variety of views and granularities. In addition, it analyzes the metrics for typical performance problems and suggests corrective actions. We demonstrate VQA using TPC-DS queries which have a wide range of query duration and complexity.
Article
Full-text available
Fct ApplyFunctor Overload PrintType Unify Typecheck PrintAbsyn Stream MLLexFun Vector Ascii LrParser JoinWithArg Join MLLrValsFun CoreLang NewParse Index Misc TyvarSet Absyn Types Normalize Modules ConRep Instantiate LrTable Backpatch PrimTypes PolyCont Initial Assembly Math Unsafe Loader CInterface CleanUp CoreFunc InLine Fastlib Core Dummy Overloads MakeMos Stamps Intmap PersStamps Pathnames Symbol Bigint Dynamic IntStrMap ArrayExt Unionfind Siblings StrgHash Env BasicTypes Tuples ModuleUtil EqTypes Fixity TypesUtil Equal Variables BareAbsyn PrintBasics PrintVal PrintDec SigMatch IntSparcD IntShare Batch RealDebug BogusDebug UnixPaths Interact ModuleComp Importer IntSparc IntNullD Linkage Prof IntNull Interp ProcessFile FreeLvar LambdaOpt Translate Opt Reorder CompSparc MCopt MCprint Nonrec MC InlineOps Unboxed dot User's Manual, October 18, 1993 Drawing graphs with dot 2 1 Basic Graph Drawing dot draws directed graphs. It reads attributed graph text #les and writes drawings, eithe...
Article
This is a duplicate publication. Someone (not an author, apparently) created a document with the title Draxving graphs vjith dot. Researchgate seems to have problems with quality control, and it appears there is no way to delete these corrupted entries.