From 941a91ec220ad13094f48457803a7f19ccf37f28 Mon Sep 17 00:00:00 2001
From: Uku Taht <uku.taht@gmail.com>
Date: Mon, 22 Nov 2021 10:58:44 +0200
Subject: [PATCH] Make better use of the index on sessions table

---
 lib/plausible/stats/base.ex | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/plausible/stats/base.ex b/lib/plausible/stats/base.ex
index 6cf84f00..d59a741a 100644
--- a/lib/plausible/stats/base.ex
+++ b/lib/plausible/stats/base.ex
@@ -127,7 +127,7 @@ defmodule Plausible.Stats.Base do
       from(
         s in "sessions",
         where: s.domain == ^site.domain,
-        where: s.timestamp >= ^first_datetime and s.start < ^last_datetime
+        where: s.start >= ^first_datetime and s.start < ^last_datetime
       )
       |> add_sample_hint(query)
 
-- 
GitLab