News for hackers. Stuff that matters.
Re:Migrating from Supabase by jgraettinger1 on Friday May 19, 2023 @06:52PM (#36007716)
Do you have an index on `updated_at` ?
Re:Migrating from Supabase by crooked-v on Friday May 19, 2023 @07:07PM (#36007833)
Yes. That's also irrelevant to the cause of the performance issues, which all happen before the ORDER BY and LIMIT even come into the picture in Postgres' query optimization.

Edit: To give a better idea of the impact of RLS here, writing up an equivalent query outside of the RLS context [1] has an under-1-second response time, where RLS turns that into 10x the time even in the most optimized case.

[1]: This kind of thing, roughly:

    SELECT *
    FROM products
    JOIN tenants ON products.tenant_id = tenants.id
    JOIN tenants_users ON tenants.id = tenants_users.tenant_id
    WHERE tenant_users.user_id = auth.uid()
    ORDER BY updated_at
    LIMIT 100