(no title)
kgeist | 9 days ago
The consensus was that returning everything is rarely what's desired, for two reasons: first, if the system grows, allowing API users to return everything at once can be a problem both for our server (lots of data in RAM when fetching from the DB => OOM, and additional stress on the DB) and for the user (the same problem on their side). Second, it's easy to forget to specify filters, especially in cases like "let's delete something based on some filters."
So the standard practice now is to return nothing if no filters are provided, and we pay attention to it during code reviews. If the user does really want all the data, you can add pagination to your API. With pagination, it's very unlikely for the user to accidentally fetch everything because they must explicitly work with pagination tokens, etc.
Another option, if you don't want pagination, is to have a separate method named accordingly, like ListAllObjects, without any filters.
alemanek|9 days ago
pigpag|7 days ago
[deleted]
Thaxll|8 days ago
If not optional then return 400, otherwise return all the results ( and have pagination ).
You should always have pagination in an API.
Philip-J-Fry|9 days ago
You can limit stress on RAM by streaming the data. You should ideally stream rows for any large dataset. Otherwise, like you say you are loading the entire thing into RAM.
jiggawatts|8 days ago
Buffering up the entire data set before encoding it to JSON and sending it is one of the biggest sources of latency in API based software. Streaming can get latencies down to tens of microseconds!
qwertyuiop_|9 days ago
MobileVet|9 days ago
PunchyHamster|9 days ago
est|9 days ago
For me it's like `filter1=*`