182/226
\begin{frame}
  \frametitle{Optimising Performance}
  
  Suppose you have a typical log of queries for your database.
  \medskip
  \pause
  
  For each query in the log:
  \begin{itemize}
  \pause
    \item Analyse average time and variance for this type of query.
      \begin{itemize}
        \item Long delays or frequent aborts may indicate contention.
      \end{itemize}
  \pause
    \item Is it is a read-only or updating query?
      \begin{itemize}
       \item Compute the read-sets and write-sets.
        \item Will it require row or table locks? Shared or exclusive?
      \end{itemize}
  \end{itemize}
  \medskip
  \pause

  How do read- and write-sets of the different queries intersect?
  \begin{itemize}
    \item What is the chance of conflicts? (delays/rollbacks)
  \end{itemize}
  \medskip
  \pause
  
  \begin{goal}{}
    Once you understand your query workload, you might improve performance by:
    \begin{itemize}
  \pause
      \item Rewriting queries to have smaller read- and write-sets.
  \pause
      \item Change scheduling of queries to reduce contention.\\
        \remark{E.g. rewrite applications to do large aggregation queries at night.}
  \pause
      \item Use a different isolation level for the queries.
    \end{itemize}
  \end{goal}
\end{frame}