Question

Bolt app is slow after adding 2,000 rows to one table

Solved · 29 views · asked by tomvibes · edited

My inventory page loads in under a second with 100 rows and takes 8 seconds with 2,000. Bolt says it's "optimized". The query is a plain select with a filter on status.

What I’ve tried

Asked Bolt to add pagination, it added a Load more button but the first load is still 8 seconds.

Comment

3 answers

Marked as helpful by the asker
olu_backend · edited

8 seconds for 2,000 rows is not the database, it's the app doing something per row. Open the network tab: I bet you see hundreds of requests. That's an N+1: the list loads, then each row fetches its own related data.

Fix it in one query with a join:

supabase.from('items').select('*, supplier(name)').eq('status', 'active').range(0, 49)

And add an index on status while you're there:

create index items_status_idx on items (status);
Comment
lena_ops · edited

Also check you are not selecting a column with a big JSON blob or a base64 image in it. select * on a table with images is a classic.

Comment