From 050d14cab767888d4040c59927f12dc4fa2609c2 Mon Sep 17 00:00:00 2001 From: David Kaufmann Date: Sun, 7 Apr 2019 23:21:55 +0200 Subject: [PATCH] layoutstuff --- ex1/main_5.tex | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/ex1/main_5.tex b/ex1/main_5.tex index a2107ce..ab0e748 100644 --- a/ex1/main_5.tex +++ b/ex1/main_5.tex @@ -6,12 +6,14 @@ Optimized query: \begin{verbatim} SELECT distinct(displayname) FROM posts p - JOIN users u ON u.id = p.owneruserid + JOIN users u ON p.owneruserid = u.id WHERE p.viewcount > u.views; \end{verbatim} Improvements:\\ -Just converted the selection to a JOIN +Just converted the selection to a JOIN. +This improves the $n_{users} + n_{users} * n_{posts}$ Seq Scans +to one JOIN and two Seq Scans. Original version: \begin{verbatim} @@ -32,6 +34,9 @@ Optimized query: SELECT score FROM comments WHERE text ILIKE 'yes%'; \end{verbatim} +Improvements:\\ +None so far. + Original version: \begin{verbatim} Planning time: 0.540 ms @@ -53,7 +58,8 @@ SELECT DISTINCT postid FROM votes WHERE postid NOT IN ( \end{verbatim} Improvements:\\ -Instead of doing about twelve million Seq Scans this is now reduces it to two Seq Scans by inverting the condition. +Instead of doing about twelve million Seq Scans this is now reduced to +two Seq Scans by inverting the condition. Original version: \begin{verbatim} @@ -84,6 +90,9 @@ SELECT p.*, c.*, u.* FROM posts p ) AND b.name IN ('Autobiographer','Supporter'); \end{verbatim} +Improvements:\\ +Converted the joins via WHERE clause to proper JOINs + Original version: \begin{verbatim} Planning time: 4.084 ms -- 2.43.0