Millions of erroneous row reads from a count statement with Prisma and planetscale

Does anyone know why this is the case
14 Replies
AdmiralGeneralAladeen
AdmiralGeneralAladeenOP•2y ago
The planetscale site says this: https://i.vgy.me/guWss3.png
sen.py
sen.py•2y ago
Does this mean getting count for paginate is effectively one query? For cost stuff
Scot
Scot•2y ago
They're probably using internal table stats the db engine keeps a count of as the estimation So that it avoids doing a full table scan Also planetscale is distributed right? Might also make that query harder and less accurate Depending on default locks I don't know much about mysql/vitess internals but that's my guess
AdmiralGeneralAladeen
AdmiralGeneralAladeenOP•2y ago
wonder why its registering millions of row reads on my dashboard
sen.py
sen.py•2y ago
Is it? I've never tried planetscale and I was worried about this use case to host my own. TBH in most scenarios an good enough estimate of count is preferred over full table scan.
AdmiralGeneralAladeen
AdmiralGeneralAladeenOP•2y ago
yeah I looked at my dashboard and millions of queries are coming from a count statement even though their site says counts shouldn't increase row reads (for billing purposes)
Scot
Scot•2y ago
do you filter at all?
AdmiralGeneralAladeen
AdmiralGeneralAladeenOP•2y ago
I did use a where with prisma
Scot
Scot•2y ago
I wonder if the count(*) is only for the full version and not for a filter (unless you perhaps have an index on the where clause?)
AdmiralGeneralAladeen
AdmiralGeneralAladeenOP•2y ago
interesting, you could be right but that would be very weird
Scot
Scot•2y ago
id followup with planetscale support
AdmiralGeneralAladeen
AdmiralGeneralAladeenOP•2y ago
I literally just have a pageview table and want to count the pageviews where page slug == slug in the db yeah I might have to ive removed that line of code for now 😂 don't want to chew up the rest of my queries for the month
Scot
Scot•2y ago
id ask and mention what you did they might refund you
AdmiralGeneralAladeen
AdmiralGeneralAladeenOP•2y ago
hopefully, unless I didn't read that page correctly 😂
Want results from more Discord servers?
Add your server