Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.
TypeScript analyticsanalytics-dashboardclickhouseelixirgoogle-analyticsmarketingopen-source-analyticsphoenixplausible-analyticspostgresqlprivacyprivacy-friendlyself-hostedsimple-analyticsstatisticstailwindcssweb-analyticswebsite-analyticswebsite-statswebsite-tracking
update ecto_ch and use ecto hints for array joins (#4456)
ruslandoga48dfce7a8b7a
diff --git a/lib/plausible/stats/custom_props.ex b/lib/plausible/stats/custom_props.exindex 5c6df48eb4..2b11d7ef92 100644--- a/lib/plausible/stats/custom_props.ex+++ b/lib/plausible/stats/custom_props.ex@@ -14,7 +14,9 @@ defmodule Plausible.Stats.CustomProps do_ ->from(e in base_event_query(site, query),- array_join: meta in fragment("meta"),+ join: meta in fragment("meta"),+ hints: "ARRAY",+ on: true,select: meta.key,distinct: true)diff --git a/lib/plausible/stats/filter_suggestions.ex b/lib/plausible/stats/filter_suggestions.exindex a94324564c..b52dfea339 100644--- a/lib/plausible/stats/filter_suggestions.ex+++ b/lib/plausible/stats/filter_suggestions.ex@@ -169,7 +169,9 @@ defmodule Plausible.Stats.FilterSuggestions dofilter_query = if filter_search == nil, do: "%", else: "%#{filter_search}%"from(e in base_event_query(site, query),- array_join: meta in "meta",+ join: meta in "meta",+ hints: "ARRAY",+ on: true,as: :meta,select: meta.key,where: fragment("? ilike ?", meta.key, ^filter_query),diff --git a/lib/plausible/stats/imported/imported.ex b/lib/plausible/stats/imported/imported.exindex ead5a5db80..36e13605a9 100644--- a/lib/plausible/stats/imported/imported.ex+++ b/lib/plausible/stats/imported/imported.ex@@ -260,7 +260,7 @@ defmodule Plausible.Stats.Imported dotype(^page_regexes, {:array, :string})))- |> join(:array, index in fragment("indices"))+ |> join(:inner, [_i], index in fragment("indices"), hints: "ARRAY", on: true)|> group_by([_i, index], index)|> select_merge_as([_i, index], %{dim0: type(fragment("?", index), :integer)diff --git a/lib/plausible/stats/sql/expression.ex b/lib/plausible/stats/sql/expression.exindex 146eae8fee..4638ea7fc4 100644--- a/lib/plausible/stats/sql/expression.ex+++ b/lib/plausible/stats/sql/expression.ex@@ -67,7 +67,11 @@ defmodule Plausible.Stats.SQL.Expression do# to work, we divide time into 15-minute buckets and later combine these# via toStartOfHourq- |> join(:array, [s], time_slot in time_slots(query, 15 * 60), as: :time_slot)+ |> join(:inner, [s], time_slot in time_slots(query, 15 * 60),+ as: :time_slot,+ hints: "ARRAY",+ on: true+ )|> select_merge_as([s, time_slot: time_slot], %{key => fragment("toStartOfHour(?)", time_slot)})@@ -103,7 +107,11 @@ defmodule Plausible.Stats.SQL.Expression do# :NOTE: This is not exposed in Query APIv2def select_dimension(q, key, "time:minute", :sessions, query) doq- |> join(:array, [s], time_slot in time_slots(query, 60), as: :time_slot)+ |> join(:inner, [s], time_slot in time_slots(query, 60),+ as: :time_slot,+ hints: "ARRAY",+ on: true+ )|> select_merge_as([s, time_slot: time_slot], %{key => fragment("?", time_slot)})diff --git a/lib/plausible/stats/sql/query_builder.ex b/lib/plausible/stats/sql/query_builder.exindex 3d1d38f085..d05389d385 100644--- a/lib/plausible/stats/sql/query_builder.ex+++ b/lib/plausible/stats/sql/query_builder.ex@@ -132,7 +132,9 @@ defmodule Plausible.Stats.SQL.QueryBuilder do{events, page_regexes} = Filters.Utils.split_goals_query_expressions(query.preloaded_goals)from(e in q,- array_join: goal in Expression.event_goal_join(events, page_regexes),+ join: goal in Expression.event_goal_join(events, page_regexes),+ hints: "ARRAY",+ on: true,select_merge: %{^shortname(query, dimension) => fragment("?", goal)},diff --git a/mix.lock b/mix.lockindex ed608a6ff9..3d5d752753 100644--- a/mix.lock+++ b/mix.lock@@ -10,7 +10,7 @@"bypass": {:hex, :bypass, "2.1.0", "909782781bf8e20ee86a9cabde36b259d44af8b9f38756173e8f5e2e1fabb9b1", [:mix], [{:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 2.0", [hex: :plug_cowboy, repo: "hexpm", optional: false]}, {:ranch, "~> 1.3", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "d9b5df8fa5b7a6efa08384e9bbecfe4ce61c77d28a4282f79e02f1ef78d96b80"},"castore": {:hex, :castore, "1.0.7", "b651241514e5f6956028147fe6637f7ac13802537e895a724f90bf3e36ddd1dd", [:mix], [], "hexpm", "da7785a4b0d2a021cd1292a60875a784b6caef71e76bf4917bdee1f390455cf5"},"certifi": {:hex, :certifi, "2.12.0", "2d1cca2ec95f59643862af91f001478c9863c2ac9cb6e2f89780bfd8de987329", [:rebar3], [], "hexpm", "ee68d85df22e554040cdb4be100f33873ac6051387baf6a8f6ce82272340ff1c"},- "ch": {:hex, :ch, "0.2.5", "b8d70689951bd14c8c8791dc72cdc957ba489ceae723e79cf1a91d95b6b855ae", [:mix], [{:db_connection, "~> 2.0", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:ecto, "~> 3.5", [hex: :ecto, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:mint, "~> 1.0", [hex: :mint, repo: "hexpm", optional: false]}], "hexpm", "97de104c8f513a23c6d673da37741f68ae743f6cdb654b96a728d382e2fba4de"},+ "ch": {:hex, :ch, "0.2.6", "c8fd53da7eb1fac475b4f3300e2010cd19d1321112cc7fdcdb8b37b28cc7b43c", [:mix], [{:db_connection, "~> 2.0", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:ecto, "~> 3.5", [hex: :ecto, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:mint, "~> 1.0", [hex: :mint, repo: "hexpm", optional: false]}], "hexpm", "775483286f6dd9266f74eefc7f5de9fb9ae0abaf5509f783d079d62641104013"},"chatterbox": {:hex, :ts_chatterbox, "0.15.1", "5cac4d15dd7ad61fc3c4415ce4826fc563d4643dee897a558ec4ea0b1c835c9c", [:rebar3], [{:hpack, "~> 0.3.0", [hex: :hpack_erl, repo: "hexpm", optional: false]}], "hexpm", "4f75b91451338bc0da5f52f3480fa6ef6e3a2aeecfc33686d6b3d0a0948f31aa"},"cldr_utils": {:hex, :cldr_utils, "2.27.0", "a75d5cdaaf6b7432eb10f547e6abe635c94746985c5b78e35bbbd08b16473b6c", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:certifi, "~> 2.5", [hex: :certifi, repo: "hexpm", optional: true]}, {:decimal, "~> 1.9 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}], "hexpm", "516f601e28da10b8f1f3af565321c4e3da3b898a0b50a5e5be425eff76d587e1"},"cloak": {:hex, :cloak, "1.1.2", "7e0006c2b0b98d976d4f559080fabefd81f0e0a50a3c4b621f85ceeb563e80bb", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "940d5ac4fcd51b252930fd112e319ea5ae6ab540b722f3ca60a85666759b9585"},@@ -32,7 +32,7 @@"double": {:hex, :double, "0.8.2", "8e1cfcccdaef76c18846bc08e555555a2a699b806fa207b6468572a60513cc6a", [:mix], [], "hexpm", "90287642b2ec86125e0457aaba2ab0e80f7d7050cc80a0cef733e59bd70aa67c"},"earmark_parser": {:hex, :earmark_parser, "1.4.39", "424642f8335b05bb9eb611aa1564c148a8ee35c9c8a8bba6e129d51a3e3c6769", [:mix], [], "hexpm", "06553a88d1f1846da9ef066b87b57c6f605552cfbe40d20bd8d59cc6bde41944"},"ecto": {:hex, :ecto, "3.11.2", "e1d26be989db350a633667c5cda9c3d115ae779b66da567c68c80cfb26a8c9ee", [:mix], [{:decimal, "~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "3c38bca2c6f8d8023f2145326cc8a80100c3ffe4dcbd9842ff867f7fc6156c65"},- "ecto_ch": {:hex, :ecto_ch, "0.3.5", "4df2e5d6b0361e7a43d2abeb7c85ea610ea3fc2004c7cfaef138588ea90386ae", [:mix], [{:ch, "~> 0.2.0", [hex: :ch, repo: "hexpm", optional: false]}, {:ecto_sql, "~> 3.9", [hex: :ecto_sql, repo: "hexpm", optional: false]}], "hexpm", "a8ce6ac1a8017e01eadc7f16a91fd7d3024bc24d81bbd4ce48030e4d70ecc25a"},+ "ecto_ch": {:hex, :ecto_ch, "0.3.8", "955b0b129fa02d534665937858903c075b9810433e6c8c2ef0b50c7889ac330b", [:mix], [{:ch, "~> 0.2.0", [hex: :ch, repo: "hexpm", optional: false]}, {:ecto_sql, "~> 3.9", [hex: :ecto_sql, repo: "hexpm", optional: false]}], "hexpm", "a77eea7438e167f2920a9ecc3769a98eaeb3e3c1f2249b11a7f4932892d7f4ca"},"ecto_network": {:hex, :ecto_network, "1.5.0", "a930c910975e7a91237b858ebf0f4ad7b2aae32fa846275aa203cb858459ec73", [:mix], [{:ecto_sql, ">= 3.0.0", [hex: :ecto_sql, repo: "hexpm", optional: false]}, {:phoenix_html, ">= 0.0.0", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:postgrex, ">= 0.14.0", [hex: :postgrex, repo: "hexpm", optional: false]}], "hexpm", "4d614434ae3e6d373a2f693d56aafaa3f3349714668ffd6d24e760caf578aa2f"},"ecto_sql": {:hex, :ecto_sql, "3.11.1", "e9abf28ae27ef3916b43545f9578b4750956ccea444853606472089e7d169470", [:mix], [{:db_connection, "~> 2.4.1 or ~> 2.5", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.11.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:myxql, "~> 0.6.0", [hex: :myxql, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.16.0 or ~> 0.17.0 or ~> 1.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:tds, "~> 2.1.1 or ~> 2.2", [hex: :tds, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.0 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "ce14063ab3514424276e7e360108ad6c2308f6d88164a076aac8a387e1fea634"},"elixir_make": {:hex, :elixir_make, "0.7.7", "7128c60c2476019ed978210c245badf08b03dbec4f24d05790ef791da11aa17c", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}], "hexpm", "5bc19fff950fad52bbe5f211b12db9ec82c6b34a9647da0c2224b8b8464c7e6c"},