Slow loading liveview logs

I currently have a function that makes an API query, returns many records.
The time it takes to load this function is on average 10 seconds.

But 5 seconds waiting for the screen to load, and very bad at the user level.

What do recommend me to do?
Do you have any examples?


  defp apply_action(socket, :index, _params, _url) do

    case myfunction() do
      {:ok, myfunction} -> 
        paginate_list = 
          Scrivener.Paginater.List.paginate(myfunction, %Scrivener.Config{page_number: 1, page_size: 10})

          |> assign(:page_title, "Page 1")
          |> assign(:table, paginate_list)
          |> assign(:table_data, paginate_list)
          |> assign(:table_count, Enum.count(myfunction))

      {:error, failed} ->
          |> assign(:table, %{})
          |> assign(:table_count, 0)
          |> put_flash(:error, "#{failed}")


It sounds like you are fetching too much at once and displaying too much at once for the browser, but we don’t have enough information. How many records?

On average 16000 records

So you are querying for 16000 records, and displaying 16000 records on the page at a given time?

I’m using scrivener to paginate.

The problem is that the page never finishes loading, even limited to 10 results per page.

Socket keeps refreshing

In my index.html I have this, to paginate
<%= Scrivener.HTML.pagination_links @table, view_style: :bootstrap_v4 %>

Scrivener.Paginater.List works with an already-loaded list: changing the page size doesn’t change how many results myfunction returns. How much of that load time is the API query?