4 ms·
The funnest part of outputting JSON from the query is that your API now basically becomes a RPC, as you don't have to do any marshalling/deserialization before
by 411111111111111 3y ago
The funnest part of outputting JSON from the query is that your API now basically becomes a RPC, as you don't have to do any marshalling/deserialization before returning the response with Content-Type application/json
Response times are really fast like that, as you probably already know. Always fun to see <10ms round trips in the browser network tab on some requests
Also no worry about n+1 queries, as they're fundamentally impossible to do like that
- password4321 3y agoI've long wondered if there would be any performance advantage for an API server to zero-copy the DB response to the browser, deserializing from the DB wire protocol on the front end. Or perhaps sending DB query results directly from DB server to browser, with the API server just initializing and securing. Thanks for pointing out how JSON from the DB is another option for moving a bit of processing elsewhere in the stack.
- tomnipotent 3y agoYou've basically described Firebase and its archetype of database.
- vbezhenar 3y agoTLS everywhere makes the whole point of zero copying obsolete. Encryption eats so much CPU that copying data around does not change anything.
- 411111111111111 3y agoIt does add a few ms, but you're overstating it. For LAN traffic, it's usually 5-8ms last time I checked on my servers.
- mattmanser 3y agoThat not what we're talking about though, we're talking about aggregating the the result of a subselect to reduce the throughput of a SQL query. I'm just pointing out it doesn't achieve that.