DEV Community

Discussion on: When query db should I check if data exists first then select it ?

Collapse
 
bgadrian profile image
Adrian B.G.

Depending on the storage and the query, most likely you will end up doing the same expensive operation, twice (network call + disk access). This optimization is done at the database level (with caching, indexing), the user (who makes the query) should not deal with it, exceptions occurs of course.