mirror of
https://github.com/penpot/penpot.git
synced 2025-05-06 00:25:54 +02:00
⚡ Add performance enhancements on telemetry related queries
This commit is contained in:
parent
0e92bcc0de
commit
ba167f256b
3 changed files with 20 additions and 9 deletions
|
@ -391,7 +391,10 @@
|
||||||
:fn (mg/resource "app/migrations/sql/0122-mod-file-data-fragment-table.sql")}
|
:fn (mg/resource "app/migrations/sql/0122-mod-file-data-fragment-table.sql")}
|
||||||
|
|
||||||
{:name "0123-mod-file-change-table"
|
{:name "0123-mod-file-change-table"
|
||||||
:fn (mg/resource "app/migrations/sql/0123-mod-file-change-table.sql")}])
|
:fn (mg/resource "app/migrations/sql/0123-mod-file-change-table.sql")}
|
||||||
|
|
||||||
|
{:name "0124-mod-profile-table"
|
||||||
|
:fn (mg/resource "app/migrations/sql/0124-mod-profile-table.sql")}])
|
||||||
|
|
||||||
(defn apply-migrations!
|
(defn apply-migrations!
|
||||||
[pool name migrations]
|
[pool name migrations]
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
CREATE INDEX profile__props__newsletter1__idx ON profile (email) WHERE props->>'~:newsletter-news' = 'true';
|
||||||
|
CREATE INDEX profile__props__newsletter2__idx ON profile (email) WHERE props->>'~:newsletter-updates' = 'true';
|
|
@ -62,19 +62,25 @@
|
||||||
[conn]
|
[conn]
|
||||||
(-> (db/exec-one! conn ["SELECT count(*) AS count FROM file"]) :count))
|
(-> (db/exec-one! conn ["SELECT count(*) AS count FROM file"]) :count))
|
||||||
|
|
||||||
|
(def ^:private sql:num-file-changes
|
||||||
|
"SELECT count(*) AS count
|
||||||
|
FROM file_change
|
||||||
|
WHERE created_at < date_trunc('day', now()) + '24 hours'::interval
|
||||||
|
AND created_at > date_trunc('day', now())")
|
||||||
|
|
||||||
(defn- get-num-file-changes
|
(defn- get-num-file-changes
|
||||||
[conn]
|
[conn]
|
||||||
(let [sql (str "SELECT count(*) AS count "
|
(-> (db/exec-one! conn [sql:num-file-changes]) :count))
|
||||||
" FROM file_change "
|
|
||||||
" where date_trunc('day', created_at) = date_trunc('day', now())")]
|
(def ^:private sql:num-touched-files
|
||||||
(-> (db/exec-one! conn [sql]) :count)))
|
"SELECT count(distinct file_id) AS count
|
||||||
|
FROM file_change
|
||||||
|
WHERE created_at < date_trunc('day', now()) + '24 hours'::interval
|
||||||
|
AND created_at > date_trunc('day', now())")
|
||||||
|
|
||||||
(defn- get-num-touched-files
|
(defn- get-num-touched-files
|
||||||
[conn]
|
[conn]
|
||||||
(let [sql (str "SELECT count(distinct file_id) AS count "
|
(-> (db/exec-one! conn [sql:num-touched-files]) :count))
|
||||||
" FROM file_change "
|
|
||||||
" where date_trunc('day', created_at) = date_trunc('day', now())")]
|
|
||||||
(-> (db/exec-one! conn [sql]) :count)))
|
|
||||||
|
|
||||||
(defn- get-num-users
|
(defn- get-num-users
|
||||||
[conn]
|
[conn]
|
||||||
|
|
Loading…
Add table
Reference in a new issue