New tikz figure, intro re-worked.

This commit is contained in:
Aaron Huber 2021-06-29 17:10:17 -04:00
parent 4cf2dd7c31
commit afd3f2bff7

View file

@ -17,7 +17,7 @@
\4 Semiring provenance nicely follows this model
\4 Set \abbrPDB\xplural use this process
\4 Model allows us to separate the deterministic from the probability computation
\AH{The part below should maybe be moved further down.}
\AH{The part below should maybe be moved further down. The order in the current draft is further down.}
\3 Assuming a bag-\abbrTIDB, when the probability of all tuples $\prob_i = 1$, the problem of computing the expected count is linear
\3 However, when $\prob_i < 1$, the problem is not linear (in circuit size)
\3 An approximation algorithm exists to bring the second step back down to linear time
@ -41,18 +41,85 @@
\begin{figure}[H]
\centering
\includegraphics[width=\textwidth]{twostep}
\caption{Two-Step Computation Model (\abbrPDB\xplural)}
\caption{Old inkscape graphic}
\label{fig:old-inkscape}
\end{figure}
\usetikzlibrary{shapes.geometric}%for cylinder
\usetikzlibrary{shapes.arrows}%for arrow shape
\usetikzlibrary{shapes.misc}
\begin{figure}[h!]
\centering
\resizebox{\textwidth}{!}{%
\begin{tikzpicture}
%pdb cylinder
\node[cylinder, text width=0.28\textwidth, align=center, draw=black, text=blue, cylinder uses custom fill, cylinder body fill=blue!10, aspect=0.12, minimum height=5cm, minimum width=2.5cm, cylinder end fill=blue!50, shape border rotate=90] (cylinder) at (0, 0) {
\tabcolsep=0.1cm
\begin{tabular}{>{\footnotesize}c | >{\footnotesize}c >{\footnotesize}c >{\footnotesize}c}
$OnTime$ & City$_\ell$ & $\Phi$ & \textbf{p}\\
\hline
& Buffalo & $L_a$ & 0.9 \\
& Chicago & $L_b$ & 0.5\\
& Bremen & $L_c$ & 0.5\\
& Zurich & $L_d$ & 1.0\\
\end{tabular}\\
\tabcolsep=0.05cm
\begin{tabular}{ >{\scriptsize}c | >{\scriptsize}c >{\scriptsize}c >{\scriptsize}c >{\scriptsize}c}
$Route$ & $\text{City}_1$ & $\text{City}_2$ & $\Phi$ & \textbf{p} \\
\hline
& Buffalo & Chicago & $R_a$ & 1.0 \\
& Chicago & Zurich & $R_b$ & 1.0 \\
%& $\cdots$ & $\cdots$ & $\cdots$ & $\cdots$ \\
& Chicago & Bremen & $R_c$ & 1.0 \\
\end{tabular}};
%First arrow
\node[single arrow, right=0.25 of cylinder, draw=black, fill=black!65, text=white, minimum height=0.75cm, minimum width=0.25cm](arrow1) {\textbf{Step 1}};
\node[above=of arrow1](arrow1Label) {$\query(\pdb)$};
\usetikzlibrary{arrows.meta}%for the following arrow configurations
\draw[line width=0.5mm, dashed, arrows = -{Latex[length=3mm, open]}] (arrow1Label)->(arrow1);
%Query output (output of step 1)
\node[rectangle, right=0.175 of arrow1, draw=black, text=purple, fill=purple!15, minimum height=4.5cm, minimum width=2cm](rect) {
\tabcolsep=0.075cm
\begin{tabular}{ >{\footnotesize}c | >{\footnotesize}c >{\footnotesize}c }
$\query_1$ & City & $\Phi$\\% & $\expct_{\idb \sim \probDist}[\query(\db)(t)]$ \\ \hline
\hline
& Buffalo & $L_a R_a$\\% & $0.9$ \\
& Chicago & $L_b R_b + L_b R_c$\\% & $0.5 \cdot 1.0 + 0.5 \cdot 1.0 = 1.0$ \\
\end{tabular}
};
%Second arrow
\node[single arrow, right=0.25 of rect, draw=black, fill=black!65, text=white, minimum height=0.75cm, minimum width=0.25cm](arrow2) {\textbf{Step 2}};
%Expectation computation; (output of step 2)
\node[rectangle, right=0.25 of arrow2, rounded corners, draw=black, fill=red!20, text=red, minimum height=4.5cm, minimum width=2cm](rrect) {
\begin{tabular}{>{\footnotesize}c}
$\mathbb{E}[\poly(\vct{X})]$\\
\hline
$1.0 \cdot 0.9 = 0.9$\\
$0.5 \cdot 1.0 + 0.5 \cdot 1.0 = 1.0$\\
\end{tabular}
};
\end{tikzpicture}
}
\caption{Two step model of computation}
\label{fig:two-step}
\end{figure}
A probabilistic database (\abbrPDB) $\pdb$ is a two-tuple ($\idb, \pd$) such that $\idb$ is the set of possible worlds $\db$ represented by $\pdb$, and $\pd$ is the associated probability distribution across each $\db$ in $\idb$. Given a query $\query$ the output of $\query(\pdb)$ is ($\idb', \pd'$) such that $\idb' = \{\query(\db_i) \suchthat i \in [\numvar]\}$ where $\numvar = \abs{\idb}$, the number of possible worlds in $\pdb$, and $\pd'$ is the resulting probability distribution over $\idb'$. As depicted in \cref{fig:two-step}, computing $\query$ as outlined above can be modeled in two steps, where the first step consists of the deterministic computation of both the query output and result tuple lineage(s) encoded in the respective representation, and the second step consists of computing the probability distributation. This computational model is nicely followed by set-\abbrPDB computation and semiring provenance, and is useful in this work for the purpose separating the deterministic computation from the probability computation.
A probabilistic database (\abbrPDB) $\pdb$ is a two-tuple ($\idb, \pd$) such that $\idb$ is the set of possible worlds $\db$ represented by $\pdb$, and $\pd$ is the associated probability distribution across each $\db$ in $\idb$. Given a query $\query$ the output of $\query(\pdb)$ is ($\idb', \pd'$) such that $\idb' = \{\query(\db_i) \suchthat i \in [\numvar]\}$ where $\numvar = \abs{\idb}$, the number of possible worlds in $\pdb$, and $\pd'$ is the resulting probability distribution over $\idb'$. The problem of computing an arbitrary $\query$ over an arbitrary $\pdb$ has been studied extensively in the literature, expecially in the context of set-$\abbrPDB\xplural$. In the deterministic setting it is well known that there exist queries $\query$ such that the runtime of $\query$ is superlinear as in the case of counting cliques, or even exponential in the size of $\query$, as is the case of a multi-join. Assuming $\query$ is linear or better, how does query computation of a $\abbrPDB$ compare to deterministic query processing?
Much work already exists regarding \abbrPDB\xplural, most of which considers $\pdb$ to be a set, meaning all possible worlds $\db$ are a \emph{set} of tuples. The problem of computing $\query$ \emph{exactly} over a set-\abbrPDB is known to be \sharpphard in the general case. The dichotomy of Dalvi and Suicu shows that for set-\abbrPDB\xplural it is the case that $\query(\pdb)$ is either polynomial or \sharpphard. Further, this dichotomy is \emph{based} on the query structure and in general is independent of the representation of the lineage polynomial.\footnote{We do note that there exist specific cases when given a specific database instance combined with an amenable representation, that a hard $\query$ can become easy, but this is {\emph not} the general case.} The hardness results for set-\abbrPDB\xplural depend on step two of the computation model.
Query processing in the $\abbrPDB$ setting can be viewed as a two step model of computation. As depicted in \cref{fig:two-step}, computing $\query$ over a $\abbrPDB$ consists of the first step, which is essentially the deterministic computation of both the query output and result tuple lineage polynomial(s) encoded in the respective representation.\footnote{Note that the runtime of the first step is the same in both the deterministic and \abbrPDB settings, since the computation of the linage is never greater than the query processing time.} The second step consists of computing the expectation of the lineage representation. This model of computation is nicely followed by set-\abbrPDB semantics and also by that of semiring provenance, and further, it is useful in this work for the purpose separating the deterministic computation from the probability computation.
A tuple independent database (\abbrTIDB) is a \abbrPDB whose tuples are treated as independent random events. Given a set-\abbrTIDB $\pdb$, $\query(\pdb)$ is essentially limited to computing the \emph{marginal} probability for a member tuple $\tup$. When it is desirable to compute either a probability distribution over the set of possible multiplicities $\tup$ or to compute certain statistical measures over the multiplicity of $\tup$, bag-\abbrPDB\xplural are a natural fit, proving very useful for posing questions such as count queries to the database. While other statistical measures can be computed, we focus primarily on computing the expected multiplicity of $\tup$, a natural interpretation of step two in the bag setting.\footnote{We consider this natural since it is true that computing the marginal probability of $\tup$ in set-\abbrPDB\xplural is essentially computing $\tup$'s expectation.} It is also compelling to consider the expected multiplicity since bag-\abbrPDB\xplural are not well studied from a theoretical perspective, and the expected count is both natural and simplistic to consider as a first building block. We consider higher moments in the appendix.\AH{Pointer here.}
A set-\abbrPDB $\pdb$ views each element $\db$ in $\idb$ to be a set of tuples. Queries over set-\abbrPDB\xplural produce set-$\abbrPDB$ output. The problem of computing $\query$ \emph{exactly} over a set-\abbrPDB is known to be \sharpphard in the general case. The dichotomy of Dalvi and Suicu shows that for set-\abbrPDB\xplural it is the case that $\query(\pdb)$ is either polynomial or \sharpphard. Further, this dichotomy is \emph{based} on the query structure and in general is independent of the representation of the lineage polynomial, meaning that the bottleneck is always in the second step of the computation model.\footnote{We do note that there exist specific cases when given a specific database instance combined with an amenable representation, that a hard $\query$ can become easy, but this is \emph{not} the general case.} In this setting, if one allows for approximation, the query processing problem can then be brought back down to quadratic time.
Traditionally, bag-\abbrPDB\xplural have long been considered to be bottlenecked in step one only, or linear in the size of query. This may partially be due to the prevalence that exists in using a sum of products (\abbrSOP) representation of the lineage polynomial amongst many of the most well-known implementations of set-\abbrPDB\xplural. Such a representation used in the bag-\abbrPDB setting \emph{indeed} allows for step two to be linear in the \emph{size} of the \abbrSOP representation, a result due to linearity of expectation.
Since set-\abbrPDB\xplural are essentially limited to computing the marginal probability of $\tup$, bag-\abbrPDB\xplural are a more natural fit for computing queries such as count queries. Traditionally, bag-\abbrPDB\xplural have long been considered to be bottlenecked in step one only, or linear in the size of query. This may partially be due to the prevalence that exists in using a sum of products (\abbrSOP) representation of the lineage polynomial amongst many of the most well-known implementations of set-\abbrPDB\xplural. Such a representation used in the bag-\abbrPDB setting \emph{indeed} allows for step two to be linear in the \emph{size} of the \abbrSOP representation, a result due to linearity of expectation.
However, it is not necessarily satisfying to stop here. Since typical implementations of \abbrPDB\xplural compute the representation of the lineage polynomial in sync with the particular choice of query plan, it is important that optimizations are allowed if we want to have a true comparison between step one and step two in bag-\abbrPDB queries. Optimizations like projection push-down produce factorized or non-\abbrSOP representations of the lineage polynomial. Our work explores whether or not step two in the computation model is \emph{always} linear in the \emph{size} of the representation of the lineage polynomial when step one of $\query(\pdb)$ is easy.\footnote{It is known that, in general, there exist queries that are \emph{not} linear in the size of the data. Such queries as multiple joins and counting cliques are specific examples of this. We are considering cases where the query is linear in the size of the data.} Indeed, if for all $i \in [\numvar]$, $\prob_i = 1$, computation is essentially a deterministic query and dominated by the first step. This changes, however, when $\prob_i < 1$, and for this case our work shows that the problem is not linear in the size of the representation.\AH{Not sure of the wording...this is \emph{true} for all representations, correct? Also, should I be more precise and say ``when $\forall i \in [\numvar]$, $\prob_i < 1$''? I don't think we consider the case of a mixture of probabilities, with some equal to 1 and some less than 1.}
However, it is not necessarily satisfying to stop here. Since typical implementations of \abbrPDB\xplural compute the representation of the lineage polynomial in sync with the particular choice of query plan, it is important that optimizations are allowed if we want to have a true comparison between step one and step two in bag-\abbrPDB queries. Optimizations like projection push-down produce factorized or non-\abbrSOP representations of the lineage polynomial. Our work explores whether or not step two in the computation model is \emph{always} linear in the \emph{size} of the representation of the lineage polynomial when step one of $\query(\pdb)$ is easy. %This works focuses on step two of the computation model specifically in regards to bag-\abbrPDB queries.
Given a bag-\abbrTIDB\footnote{A \abbrTIDB is a \abbrPDB such that each tuple is considered to be an independent random event.} $\pdb$, when the probability of all tuples $\prob_i = 1$, the problem of computing the expected count is linear, and we have deterministic runtime. However, for the class of \abbrTIDB\xplural with $\prob_i < 1$, the problem of computing the expected count (step two of the computation model) in general is no longer linear in the size of the lineage polynomial representation. This work focuses on analyzing step two of the query processing problem over bag-\abbrPDB queries, specifically, ``Given a lineage polynomial generated by a query $\query$, compute the expected multiplicity.'' We also introduce an approximation algorithm of the expected count of $\tup$ from the bag-\abbrPDB query $\query$ which runs in linear time.
As noted, bag-\abbrPDB query output is a probability distribution over the possible multiplicities of $\tup$, which is a stark contrast to the marginal probability paradigm of set-\abbrPDB\xplural. Further, from a theoretical perspective, not much work has been done considering bag-\abbrPDB\xplural. Focusing on computing the expected count of $\tup$ is therfore a natural (and simplistic) statistic to consider in further developing the theoretical foundations of bag-\abbrPDB\xplural. There are indeed other statistical measures that can be computed, but which are beyond the scope of this paper, though we do consider higher moments, which can be found in the appendix.
%A tuple independent database (\abbrTIDB) is a \abbrPDB whose tuples are treated as independent random events. Given a set-\abbrTIDB $\pdb$, $\query(\pdb)$ is essentially limited to computing the \emph{marginal} probability for a member tuple $\tup$. When it is desirable to compute either a probability distribution over the set of possible multiplicities of $\tup$ or to compute certain statistical measures over the multiplicity of $\tup$, bag-\abbrPDB\xplural are a natural fit, proving very useful for posing questions such as count queries to the database. While other statistical measures can be computed, we focus primarily on computing the expected multiplicity of $\tup$, a natural interpretation of step two in the bag setting.\footnote{We consider this natural since it is true that computing the marginal probability of $\tup$ in set-\abbrPDB\xplural is essentially computing $\tup$'s expectation.} It is also compelling to consider the expected multiplicity since bag-\abbrPDB\xplural are not well studied from a theoretical perspective, and the expected count is both natural and simplistic to consider as a first building block. We consider higher moments in the appendix.\AH{Pointer here.}
%\footnote{It is known that, in general, there exist queries that are \emph{not} linear in the size of the data. Such queries as multiple joins and counting cliques are specific examples of this. We are considering cases where the query is linear in the size of the data.} Indeed, if for all $i \in [\numvar]$, $\prob_i = 1$, computation is essentially a deterministic query and dominated by the first step. This changes, however, for $\prob_i < 1$, a case for which our work shows that in general the problem is not linear in the size of the representation.
Our work focuses on the following setting for query computation. Inputs of $\query$ are set-\abbrPDB\xplural, while the output of $\query$ is a bag-\abbrPDB. This setting, however, is not limiting as a simple generalization exists, which involves assigning a unique id to each tuple of bag-\abbrPDB inputs.
@ -195,7 +262,7 @@ With $\Phi^2$ as an example, we have:
\widetilde{\Phi^2}(L_a, L_b, L_c, L_d)
=&\; L_aL_b + L_bL_d + L_bL_c + 2L_aL_bL_d + 2L_aL_bL_c + 2L_bL_cL_d
\end{align*}
It can be verified that the reduced polynomial parameterized with each variable's respective marginal probability is a closed form of the expected count (i.e., $\expct\pbox{\Phi^2} = \widetilde{\Phi^2}(\probOf\pbox{L_a=1},$ $\probOf\pbox{L_b=1}, \probOf\pbox{L_c=1}), \probOf\pbox{L_d=1})$). In fact, we show in \Cref{lem:exp-poly-rpoly} that this equivalence holds for {\em all} UCQs over TIDB/BIDB.
It can be verified that the reduced polynomial parameterized with each variable's respective marginal probability is a closed form of the expected count (i.e., $\expct\pbox{\Phi^2} = \widetilde{\Phi^2}(\probOf\pbox{L_a=1},$ $\probOf\pbox{L_b=1}, \probOf\pbox{L_c=1}), \probOf\pbox{L_d=1})$). In fact, we show in \Cref{lem:exp-poly-rpoly} that this equivalence holds for {\em all} $\raPlus$ queries over TIDB/BIDB.
To prove our hardness result we show that for the same $Q$ considered in the running example, the query $Q^k$ is able to encode various hard graph-counting problems. We do so by analyzing how the coefficients in the (univariate) polynomial $\widetilde{\Phi}\left(p,\dots,p\right)$ relate to counts of various sub-graphs on $k$ edges in an arbitrary graph $G$ (which is used to define the relations in $Q$). \AH{What is meant by the following sentence?}For the upper bound it is easy to check that if all the probabilties are constant then ${\Phi}\left(\probOf\pbox{X_1=1},\dots, \probOf\pbox{X_n=1}\right)$ (i.e. evaluating the original lineage polynomial over the probability values) is a constant factor approximation. \AH{Why do we say `approximation'? This is a linear {\emph exact} computation.} To get an $(1\pm \epsilon)$-multiplicative approximation we sample monomials from $\Phi$ and `adjust' their contribution to $\widetilde{\Phi}\left(\cdot\right)$.