<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>On Using Materialized Views for Query Execution in Distributed Real-Time Database Management Systems</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>© Alexander Zharkov</string-name>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Penza State University zharkov@sura.ru</string-name>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Related Works</string-name>
        </contrib>
      </contrib-group>
      <abstract>
        <p>This paper describes how materialized views could be used in distributed Real-Time Database Management System. We provide algorithm for dynamic materialized views building and cost evaluation. The main difference of provided method is that we take into account temporal properties of base relations and data manipulation operations. Experimental part provides algorithm which builds materialized view for given subset of physical query execution plans.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1 Preface</title>
      <p>Real-time database management systems are the
database management systems which can provide
reliable queries execution in predictable time. Real-time
databases use timing constraints to provide valid query
results. Inability of conventional databases to work in
such circumstances is the main reason to use real-time
databases in a wide range of modern industrial
applications.</p>
      <p>The main are of our interests is the process control
applications and using real-time database .management
systems to store data for SCADA systems and they
components. Modern real-time system should be able to
store temporal data, handle time-critical queries,
support priority scheduling and interact in dynamic
environment. Our previous work was devoted to the
scheduling policies in real-time database management
systems. In this work we have concentrated on effective
queries processing in distributed environment with
some restrictions. The restrictions to the testing
environment reflect some features of the commonly
used computational system in the domain area we are
interested in – process control.</p>
      <p>Let us review the main features of the computational
system which we are using in test environment:
 computational system is heterogeneous – hosts
have different workload and different functions.
There are 3 type of nodes – “server”, “sensor”
and “user”;
Our research area is placed in the intersection of
different areas such as transactions processing, queries
optimization, real-time databases, active and temporal
database management systems. Common transaction
handling aspects in Real-Time DBMS were considered
in [1, 2, and 4]. Issues with Timing constraints were
described in [3]. Work [5] describes commonly use
optimization techniques. We have used some of these
techniques in implementation of our query subsystem.
Modern line of investigations in multi-query
optimizations which used in materialized views support
subsystem represented in [6]. Works [7] and [8] are
concerned with queries processing which uses both
conventional relations and materialized views to
produce query result. Our work [9] and [10] describes
real-time database management system prototype and
transaction handling policies used in our experiments.
In materialized views support system we have used
elements of the lattice theory [11] to describe some
properties of the materialized views support subsystem.</p>
    </sec>
    <sec id="sec-2">
      <title>2 Query Execution Plan Representation</title>
      <p>The materialized views management subsystem uses
the following input information:
 query plans batch;
 source database structure;
 statistical information provided by main
server database;</p>
      <p>During subsystem initialization materialized views
management subsystem transforms input query batch to
internal format which helps to minimize execution and
update costs. We use lattice representation based query
batch as optimal structure for update traces. Internal
representation contains mapping from physical query
plan items to materialized data items and update support
structure.</p>
      <p>One of tasks is transformation from physical query
plan to internal representation. Usually query execution
plan represented by Directed Acyclic Graph (DAG).
Formally query execution plan used in our experiments
could be represented as follows:</p>
      <p>
        G p  Top , Op , Dp , Rp , (
        <xref ref-type="bibr" rid="ref1">1</xref>
        )
where Top – set of supported operations;
      </p>
      <sec id="sec-2-1">
        <title>Op – operational nodes set;</title>
      </sec>
      <sec id="sec-2-2">
        <title>Dp – data nodes set;</title>
        <p>Rp – arcs set which represents relations between
nodes;</p>
        <p>This model has the following restrictions:
 Operational nodes could be connected only with
data nodes and data nodes could be connected only
with operational nodes;
 Operational nodes have only one upcoming arc and
one ore more incoming arcs (for conventional
relation operations no more then 2 arcs)
 Data nodes can have no more then one upcoming
and one incoming arc;
 Data nodes can represent not only conventional
relations but also other data nodes like indexes or
hashes;
Here To ={Join, Union, Projection, Selection},
O = {Join(A,B), Join(AB,C)},
D = {A, B, C, AB, ABC},</p>
        <p>R = {(A, Join(A,B)), (B, Join(A,B)), (Join(A,B),
AB), (AB, Join(AB, C)), (C, Join(AB, C)), (Join(AB,
C), ABC)}</p>
        <p>A, B, С – source database relations and AB, ABC –
results of the join operation.</p>
        <p>Physical query execution plan in our subsystem is
represented as</p>
        <p>
          G pRT  TpRT , O pRT , D pRT , R pRT , (
          <xref ref-type="bibr" rid="ref2">2</xref>
          )
        </p>
        <p>TpRT ={ScanSelect,</p>
        <sec id="sec-2-2-1">
          <title>ScanSelectID, where</title>
        </sec>
        <sec id="sec-2-2-2">
          <title>ScanIndex,</title>
        </sec>
        <sec id="sec-2-2-3">
          <title>ScanSort,</title>
        </sec>
        <sec id="sec-2-2-4">
          <title>NestedLoopsJoin,</title>
          <p>NestedLoopsIndexJoin, HashJoin}, a set of operational
nodes types;</p>
          <p>D RT  d   j, x : j  1, l, l  D RT , x  X RT 
p p OBJ
(3) — data nodes set which represents the pair: data
node index j and data object x which belongs to X RT
OBJ
all database objects;</p>
          <p>o  i, m, Ao  : i  1, n, n  O RT ,
O pRT  m  TpRT , p  (4)
 
 Ao  ao  Axi  | xi  X ORBTJ  

— operational nodes set. Each node consists of node
identifier, transaction type and set of attributes used in
transaction execution;</p>
          <p>R pRT  r  oi , d j  : oi  O pRT , d j  D pRT 
r  d j , oi  : oi  O pRT , d j  D pRT 
(5) — set of relations between operational and data
nodes. These relations are relations of consequence. Set
RpRT represents ordering relationship and the G pRT
model itself is partially ordered on consequence
relation.</p>
          <p>Query execution batch
Query execution batch is represented as
Pqueries  G plans , Qqueries , RQP , (6)
where Qqueries — a set of the parameterized queries
which are used for quick access to the materialized
results;</p>
          <p>G plans</p>
          <p>
            — set of query execution plans generated
for each query. Each query plan is represent as G p ,(
            <xref ref-type="bibr" rid="ref2">2</xref>
            );
          </p>
          <p>RQP  rQP : rQP  q, G p , q  Qqueries , G p  G plans
— set of relations which represents mapping between
initial query and appropriate subset of query execution
plans.</p>
        </sec>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>3 Internal materialized views representation</title>
      <p>During materialized views management system
initialization query execution plans batch is transformed
to the internal representation suitable for regular update
in real-time mode. For this purpose query plan elements
are sorted in and combined into single batch where
elements are ordered by inclusion relation to minimize
updates count. In our system materialized views batch is
represented as lattice which is defined as:</p>
      <p>L  (V * , R  ) , (6)
where V * – lattice nodes set which corresponds to</p>
      <sec id="sec-3-1">
        <title>G p query execution graphs;</title>
        <p>R </p>
        <p>– model signature which specifies ordering
relationship on lattice nodes set.</p>
        <p>This model should satisfy to the following
restrictions [11]:
 model should have antireflexiveness property–


a V * , a, a  R  (7);
model should
have asymmetric
property
a,b V , a,b  R   b, a  R  (8);
a, b, c V ,  a, b  R  and b, c  R  
model should
have transitivity
property
(9);
–
–
  a, c  R  </p>
        <p>Every node v* V * represents object which
could be materialized. Each lattice node is based on
query execution plan node and could be defined as
follows:
v*  v', AV ,Ccost , X data , (10)
where v' DPRT  OPRT
node from</p>
        <p>G p  G plans
dependency between lattice node and query execution
plan node is used during query evaluation.</p>
        <p>– operational or data
graph nodes set. This
 Ao , v' O RT
AV   P –
aV | aV  Ax, x  X ORBTJ , v' DPRT
database relation attributes set from the attributes to be
materialized. Here Ao – set of attributes used in
operational node for cases when this lattice node is
based on operational nodes set. Ax – x relation
schema, which is base relation for data node for cases
when lattice node is based on data node of the query
execution plan;</p>
        <p>Ccost  Creuse , Cupdate , Cretrieve
 – set of cost
estimates for this materialized view node, where Creuse
– cost of materialized view node reuse in cases if node
will be materialized, Cupdate – data update cost for
cases when node is materialized, Cretrieve
– data
retrieving cost for cases when node is not materialized
and appropriate query is executed on main database
server. These estimates could be enhanced but it was
enough for our prototype;</p>
        <p>
X data  
x | x  X ORBTJ 
–data
relations
set
created for data materialization in this node. This set is
empty for cases when data should not be materialized in
current node. If this set is not empty it contains set of
data objects which contains base operational nodes
result.</p>
        <p>Figure 2 represents internal materialized views
representation generated by visualisation part of our
lattice building test application</p>
      </sec>
    </sec>
    <sec id="sec-4">
      <title>4 Query execution plans batch transformation method</title>
      <p>This part describes method used for transformation
query execution plans batch to the internal materialized
views representation. This method is based on building
lattice using transitive closure for identifying base
nodes.</p>
      <p>Algorithm contains three main parts:
Building generating sets. Each potential node has
corresponding generating set which contains set of
attributes used in operational or data node.</p>
      <p>Building lattice which corresponds to rules (7), (8)
and (9)
Cost evaluation for each node and identifying
nodes to be materialized.</p>
      <p>Generative sets building algorithm</p>
      <p>Let V *</p>
      <p>materialized view set to be filled. At the
first step this set is empty. Let
1.1 Build attributes set Ad  A( x), x  X ORBTJ , which
is subset of the base relation schema.</p>
      <p>v*  v', AV , Ccost , X data
where
1.2</p>
      <sec id="sec-4-1">
        <title>Create node</title>
        <p>v'  d , AV  Ad , X data  </p>
        <sec id="sec-4-1-1">
          <title>1.3 Add node v* to the V * set</title>
          <p>*
Subroutine Add ( A , A )</p>
          <p>V V
1. i  0 , n  R 
2. If i  n , then move to the step 3, else move to
the step 8
3. If ri  rx, y : x  A , then move to the step 4,
V
else move to the step 7
4. If y  A* , then move to the step 9, else move to</p>
          <p>V
the step 5
5. z  AV*  y</p>
          <p>*
6. If z  A , then move to the step 9, else move to</p>
          <p>V
the step 7
7. i  i  1 , move to the step 2
8. Add relation r A , A*  to the R  signature</p>
          <p>V V</p>
        </sec>
      </sec>
      <sec id="sec-4-2">
        <title>9. Exit</title>
        <p>Let us review main iterative algorithm
1. i  0 , n  V *
2. If i  n , then move to the step 3, else move to
the step 12
3. j  0
4. If j  n , then move to the step 5, else move to
2. For each operational node o  i, m, A  O RT
o P
2.1 Create node v*  v' , AV , Ccos t , X data , where
the step 11
5. AV*  AVi  AVj
v'  o , AV  Ao , X data  </p>
        <sec id="sec-4-2-1">
          <title>2.2 Add node v* to the V * set</title>
          <p>3. Create node v , which has
AV </p>
          <p> AV vi*  ,
i1, V *
X data   . This node represents structural unit –
superset of all attributes.</p>
        </sec>
        <sec id="sec-4-2-2">
          <title>4. Add node v to the V * set</title>
          <p>As the result we have V * set, which is the basis for
lattice building.</p>
          <p>Lattice signature building algorithm
AV vi* , vi*  V * , i  1, n, n  V *</p>
          <p>Second step goal is to build lattice signature R 
which represents inclusion relation defined on V * set.
This step contains consecutive pair wise intersection for
sets.</p>
          <p>If
intersection result is not empty set then new set is used
as new node in lattice. And this new node is added as
base for two nodes used in intersection.</p>
          <p>This algorithm could be divided into two parts:
 Subroutine which adds relation to the relation set
and checks new relations to satisfy (7), (8) and (9)
restrictions;
</p>
        </sec>
        <sec id="sec-4-2-3">
          <title>Main iterative part where V *</title>
          <p>looked through.</p>
          <p>Let us review add subroutine:
set elements are</p>
          <p>6. If AV*   , then move to the step 7, else move
to the step 10</p>
          <p>7. If AVk  AV* : AVk V * , then move to the step</p>
        </sec>
      </sec>
      <sec id="sec-4-3">
        <title>8, else move to the step 10</title>
        <sec id="sec-4-3-1">
          <title>8. Call Add( AVi , AVk )</title>
        </sec>
        <sec id="sec-4-3-2">
          <title>9. Call Add( AVj , AVk )</title>
          <p>10. j  j  1, move to the step 4
11. i  i  1 , move to the step 2
12. Exit</p>
          <p>This algorithm is used to find the most frequently
used nodes. But sometimes (for example in cases when
there are not so much candidates to the materialization)
we can use method less strict method. This enhances
base set for cost estimation and could give us more
efficient result for small lattice.</p>
          <p>The algorithm for building additional nodes
1. Vc*urrent  V *
2. If Vc*urrent  0 , then move to the step 3, else
move to the step 17
3. i  0 , n  Vc*urrent
4. If i  n , then move to the step 5, else move to
the step 16
5. j  0
6. If j  n , then move to the step 7, else move to
the step 15
7. AV*  AVi  AVj
8. If AV*   , then move to the step 9, else move
to the step 14</p>
          <p>9. If AVk  AV* : AVk Vc*urrent , the move to the
step 12, else move to the step 10
10. Add AV* to the V * set
11. Add AV* to the Vn*ext set for the next iteration
12. Call Add( AVi , AVk )
13. Call Add( AVj , AVk )
14. j  j  1, move to the step 6
15. i  i  1 , move to the step 4
16. Vc*urrent  Vn*ext , move to the step 2
17. Exit</p>
          <p>This algorithm uses the same subroutine Add as
previous algorithm.</p>
          <p>Cost estimation for lattice nodes</p>
          <p>We use iterative cost estimation method which
evaluates cost for each node using optimal cost
evaluation for base nodes. The criterion function is
defined as F </p>
          <p> minCost ' vq ,Tuse  (11)
vqVquery</p>
          <p>Cost’ is subsequent query execution estimation and
is defined as:
Cost ' v, Tuse  
min  C reuse  X data   Cupdate  X data , Tuse , X data
 C retrieve  X data , Tuse , X data  
(12)</p>
          <p>v'V '</p>
        </sec>
      </sec>
      <sec id="sec-4-4">
        <title>Retrieve cost is defined as</title>
        <p>Cretrieve </p>
        <p> minCost v' ,Tuse , (13)
where V '  V * ,V '  v': r  rv, v', r  R   –
is set of node which are base nodes for current node.</p>
      </sec>
    </sec>
    <sec id="sec-5">
      <title>5. Implementation results</title>
      <p>Proposed materialized views model was used in
distributed real-time database management system
prototype for client transactions performance
evaluation. For debugging and visual representation of
the materialized views special demonstration program
was developed which uses algorithms described in
section 4 and builds picture represented in figure 2.
Algorithms from section 4 were implemented both in
real-time DBMS prototype and in test application.</p>
      <p>In experimental investigation we plan to focus on 3
main directions:
 experiments with the test application which can
visualize internal materialized views
representation – this part needed to investigate
various combinations of the query batches;
 set of experiments with transaction handling
policies to verify what parameters should be
used in “user” nodes and “server” nodes;
 set of experiments with different objects to be
materialized – the main idea of this part is to
investigate how temporary objects (such as
temporary indexes and hashes) could be used to
increase query processing effectiveness.</p>
      <p>For now we have completed first part of
experiments – building visual representation of the
materialized views based on the user queries (you can
see example picture in Figure 2).</p>
    </sec>
    <sec id="sec-6">
      <title>6. Further Work</title>
      <p>As further work we consider performing
experiments on rest two directions using implemented
algorithms as part of the distributed database
management system prototype. For now we have
prepared test database which schema corresponds to the
typical database used in process control.</p>
      <p>Another direction of the further work is integration
of the proposed algorithms to the commercial system
which will provide database-like access to the
OPCserver data with ability to transfer data to the
mainstream database management systems.
and Information Science and Engineering. Volume
1, Number 2, 2007
[9] A. V. Zharkov. Distributed Real-Time Database
Management System Prototype for Transaction
Handling Methods Simulation. In Proceedings of
scientific and technical conference "Microsoft
Technologies in Programming Theory and</p>
      <p>Practice". N. Novgorod, 2007
[10] Zharkov A. Performance Evaluation of Transaction
Handling Policies on Real-Time DBMS Prototype.
Proceedings of the Fourth Spring Young
Researcher's Colloquium on Database and
Information Systems (SYRCoDIS'2007). Institute
for System Programming of the Russian Academy
of Sciences. Moscow, 2007.
http://CEUR</p>
      <p>WS.org/Vol-256/
[11] Birkhoff G. Lattice theory. Providence. Rhode
Island. 1967</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>K.</given-names>
            <surname>Ramamritham</surname>
          </string-name>
          .
          <article-title>Time for Real-Time Temporal Databases</article-title>
          . Dept. of Computer Sc.,
          <source>Univ. of Massachusetts</source>
          , 1995
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
           , [2]
          <string-name>
            <given-names>J. R.</given-names>
            <surname>Haritsa</surname>
          </string-name>
          ,
          <string-name>
            <given-names>K.</given-names>
            <surname>Ramamritham.</surname>
          </string-name>
          Real-Time 
          <article-title> Database Systems in the New Millennium</article-title>
          . Dept. of  Computer Sc.,
          <source>Univ. of Massachusetts</source>
          ,
          <year>1999</year>
          [3]
          <string-name>
            <given-names>Chanjung</given-names>
            <surname>Park</surname>
          </string-name>
          , Seog Park, Sang H. Son.
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          <string-name>
            <given-names>Multiversion</given-names>
            <surname>Locking</surname>
          </string-name>
          <article-title>Protocol with Freezing for Secure Real-Time Database Systems</article-title>
          .
          <article-title>IEEE transactions on knowledge and data engineering</article-title>
          , vol.
          <volume>14</volume>
          , no.
          <issue>5</issue>
          , september/october
          <year>2002</year>
          [4]
          <string-name>
            <surname>John</surname>
            <given-names>A Stankovic</given-names>
          </string-name>
          , Marco Spuri, Marco Di Natale,
          <string-name>
            <given-names>Giorgio</given-names>
            <surname>Buttazzoy</surname>
          </string-name>
          .
          <source>Implications of Classical Scheduling Results For Real-Time Systems. June 23</source>
          <year>1994</year>
          [5]
          <string-name>
            <surname>Joseph</surname>
            <given-names>M.</given-names>
          </string-name>
          <string-name>
            <surname>Hellerstein</surname>
          </string-name>
          .
          <article-title>Optimization and Execution Techniques for Queries with Expensive Methods</article-title>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          <article-title>Doctor of Philosophy dissertation</article-title>
          . University of Wisconsin-Madison,
          <year>1995</year>
          [6]
          <string-name>
            <given-names>Prasan</given-names>
            <surname>Roy</surname>
          </string-name>
          .
          <article-title>Multy-Query Optimization and Applications</article-title>
          .
          <source>Doctor Of Philosophy degree thesis</source>
          , Department of Computer Science and Engineering, Indian Institute of Technology, Bombay,
          <year>2000</year>
          [7]
          <string-name>
            <given-names>Hoshi</given-names>
            <surname>Mistry</surname>
          </string-name>
          , Prasan Roy,
          <string-name>
            <given-names>S.</given-names>
            <surname>Sudarshan</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Krithi</given-names>
            <surname>Ramamritham</surname>
          </string-name>
          .
          <article-title>Materialized View Selection and Maintenance Using Multi Query Optimization</article-title>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          <string-name>
            <surname>ACM SIGMOD Conference Proceedings</surname>
          </string-name>
          ,
          <year>2001</year>
          [8]
          <string-name>
            <given-names>Jiratta</given-names>
            <surname>Phuboonob</surname>
          </string-name>
          , and
          <string-name>
            <given-names>Raweewan</given-names>
            <surname>Auepanwiriyakul</surname>
          </string-name>
          .
          <article-title>Selecting Materialized Views Using Two-Phase Optimization with Multiple View Processing Plan</article-title>
          .
          <source>International Journal of Computer</source>
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>