© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•3y ago•
2 replies
reese

Slow Join Filter via Javascript Client (SQL is fast)

Hey there,

I'm creating a new JS Client query to retrieve rows according to a filter on a foreign table via reference. Something like this:

  const { data, error } = await supabase
    .from('rooms')
    .select(`*, hotels!inner (*)`)
    .eq('hotels.company_id', '1234');
  const { data, error } = await supabase
    .from('rooms')
    .select(`*, hotels!inner (*)`)
    .eq('hotels.company_id', '1234');


This query times out each time it's run with the error:
{
  error: {
    code: '57014',
    details: null,
    hint: null,
    message: 'canceling statement due to statement timeout'
  }
}
{
  error: {
    code: '57014',
    details: null,
    hint: null,
    message: 'canceling statement due to statement timeout'
  }
}


When I run this query using a Postgres SQL command, however, it completes in a second.
SELECT *
FROM rooms r
         join hotels h on r.hotel_id = h.id
where h.company_id = '1234'
SELECT *
FROM rooms r
         join hotels h on r.hotel_id = h.id
where h.company_id = '1234'


(I've changed the names of the tables from the originals)
Stats
rooms: 609956
hotels: 159549

Additionally, I've added indexes to both:
1. rooms.hotel_id
2. hotels.company_id

Does anyone know why this command may be so slow, only while using the JS Client
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

inner join really slow
SupabaseSSupabase / help-and-questions
4y ago
RPC call slower via supabase client than via sql editor in the browser
SupabaseSSupabase / help-and-questions
6mo ago
How to filter main query using subqueries via JS Client?
SupabaseSSupabase / help-and-questions
3y ago
SQL Join Supabase REST API
SupabaseSSupabase / help-and-questions
4y ago