156/212
\begin{frame}
  \frametitle{Multi-Granularity Locking}
  
  \begin{goal}{}
    Decide the granularity of locks held \emph{for each transaction}.\\
    \remark{Depending on the characteristics of the queries.}
  \end{goal}
  \pause\smallskip
  
  For example, acquire a \emph{row lock} for:
  \begin{code}{\textwidth}{$Q_1$: row-selecting query (\sql{id} is a key)}
    \small
    \BUseVerbatim{query}
  \end{code}
  \pause\vspace{-1.5ex}
  
  For example, acquire a \emph{table lock} for:
  \begin{code}{\textwidth}{$Q_2$: table scan query}
    \small
    \BUseVerbatim{query2}
  \end{code}
  \pause\vspace{-1.5ex}
  
  \begin{alertblock}{}
    How do such transactions know of each others locks?\\
    \remark{Note that the locks are on different granularity levels!}
  \end{alertblock}
\end{frame}