canceling statement due to statement timeout

I am getting timeout on a query but only after exceeding 400 records or so. I have a limit of 10 records per request and this query in a database manager is extremely fast but here I get timeout.
If I query before 400 records I get no error, could it be because of the amount of nesting I have? If I remove some of that nesting it is fixed, maybe supabase does not handle the join well?
I see that the relations of the keys are correctly configured, so it is not the problem.

In the supabase editor it works, returning about 10k rows without a problem in 8 seconds, while the limit of 10 takes about .5 seconds

export async function getInspectionBookings(
  client: Client,
  startIndex?: number
) {
  console.log(startIndex, startIndex! + 10)
  return client
    .from(table)
    .select(
      `
            *,
            property,
            object_form (
              formd (
                id,
                formt_id,
                sub_category(
                  sub_category_id,
                  category (
                    id
                  )
                )
              )
            ),
            clients{
              id
            ,
            workspace{
              id
            } 
            `,
      {
        count: "exact",
      }
    )
    .range(startIndex || 0, startIndex ? startIndex + 10 : 10)
  // .throwOnError()
}
Was this page helpful?