optimise product queries: skip image blobs, limit listing preloads, add composite index
All checks were successful
deploy / deploy (push) Successful in 1m29s
All checks were successful
deploy / deploy (push) Successful in 1m29s
The listing preload (images: :image) was loading the full images table row including the data BLOB column (~3MB per page). Now only loads :id and :source_width. Listing preloads also limited to first 2 images (primary + hover) since product cards don't use the rest. Added composite indexes on (visible, status, inserted_at) and (visible, status, category) to eliminate the TEMP B-TREE sort SQLite was doing. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -7,7 +7,7 @@ defmodule BerrypodWeb.Admin.ProductShow do
|
||||
|
||||
@impl true
|
||||
def mount(%{"id" => id}, _session, socket) do
|
||||
case Products.get_product(id, preload: [:provider_connection, images: :image, variants: []]) do
|
||||
case Products.get_product_with_preloads(id) do
|
||||
nil ->
|
||||
socket =
|
||||
socket
|
||||
|
||||
@@ -64,7 +64,7 @@ defmodule BerrypodWeb.Admin.Products do
|
||||
@impl true
|
||||
def handle_event("toggle_visibility", %{"id" => id}, socket) do
|
||||
product =
|
||||
Products.get_product(id, preload: [:provider_connection, images: :image, variants: []])
|
||||
Products.get_product_with_preloads(id)
|
||||
|
||||
case Products.toggle_visibility(product) do
|
||||
{:ok, updated} ->
|
||||
|
||||
Reference in New Issue
Block a user