I always just select data then check if returned data is null or not, but I wonder if that is a good way.
But if I check for data exists then that will make 2 call to db, 1 for check and 1 for select, is this good ?
Or maybe I just overthinking it :).
What are your though about this ?
Thank you
Latest comments (2)
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.
I actually wrote a post that talks about tradeoffs of making lots of database hits even if they are simple. You might find it helpful!
In your scenario it really depends.