Joke Collection Website - Cold jokes - Try to avoid calling the database or API twice. What is it?

Try to avoid calling the database or API twice. What is it?

What does this question mean?

What is the reason to avoid calling the database or API twice as much as possible?

If a business request involves a database /API, you should call it once as much as possible, because accessing the database /API needs to create a connection, and the database /API needs to release the connection to you after the access, which requires resources to do these things. How can we save resources to the maximum extent? The number of requests is beyond our control, so what we can control is to use database /API resources at least when processing requests. Therefore, it is necessary to call 1 time as much as possible, so as to achieve the purpose of saving resources to the greatest extent.

I remember a little joke, which vividly illustrates this point.

It is said that there is a small shop, and some things are so high that the boss needs to climb a ladder to get them. One day, three customers came. The first customer said, boss, I want a pack of instant noodles. The boss climbed the ladder and brought him a pack of instant noodles. The second customer said, boss, I also want a pack of instant noodles. Reluctantly, the boss climbed the ladder and handed him a packet of instant noodles. At this time, the boss pointed to the third customer and said, do you want a pack of instant noodles, too? The third customer shook his head, so the boss got down from the ladder and asked the third customer, What do you want? The third customer said, I want two packs of instant noodles.

In the joke above, if the customer's purchase of instant noodles is a business request, then our database /API is the boss, and we climb the ladder to hand the instant noodles to the customer. If a customer wants two packs of instant noodles, as a boss, we have two ways. One is to climb a ladder to get a bag of instant noodles, and then climb a ladder to get a bag of instant noodles. The other is to climb a ladder to get two packs of instant noodles at once. What would you do if it were you?