https://supabase.com/ logo
#help
Title
# help
v

VΞLO

04/20/2022, 9:17 PM
Is the following the most concise way of obtaining a count of all rows?
const { count } = await supabase.from('some_table').select('*', {count: 'exact', head: true})
n

Needle

04/20/2022, 9:18 PM
Hello @VΞLO! This thread has been automatically created from your message in #843999948717555735 a ``few seconds ago``. Pinging @User so that they see this as well! Want to unsubscribe from this thread? Right-click the thread in Discord (or use the ... menu) and select Leave Thread to unsubscribe from future updates. Want to change the title? Use the
/title
command! We have solved your problem? Click the button below to archive it.
g

garyaustin

04/20/2022, 9:23 PM
Without looking into what PostgREST does, I'd say picking a single column instead of * MIGHT be better. It could make no difference depending on the rest of the flow at the server.
n

Needle

04/20/2022, 9:23 PM
VΞLO (2022-04-20)
v

VΞLO

04/20/2022, 9:25 PM
thanks, did not think of that!
especially perhaps the primary key field?
g

garyaustin

04/20/2022, 9:27 PM
Well it would use that anyway to do the count, just saying one column because I'm not sure how far "head" is propagated to not return data. If it is just at the http interface then you might get a small benefit on the actual database side, but even that may not be true based on how the database reads the table into memory. Basically it can't hurt though.