1

I got the answer "Salesforce is a multitenent environment and performing such query including wildcard can affect other tenants" but I do not understand how other tenants will be affected by this Query.Most of the limitations in salesforce like limit in soql queries and No. of Dml in one context is limited and the reason is shared Environment(Multitenant).I actually want to know how one tenant can affect other tenant ?

1 Answer 1

8

Salesforce is a shared resource, which means that many tenants are using the system all at once. Also, some odd 80% of the traffic that Salesforce handles are actually from API calls, not Apex Code, Visualforce, or Lightning. As such, forcing developers to specify the fields they want to use helps alleviate API traffic so that things can flow smoothly. The limitations in Visualforce and Apex Code are important, but a relatively small portion of the resources used by the platform.

To see what I'm talking about, consider two queries that are run at the same time. The first queries two fields and returns 50,000,000 rows, and the second queries 500 fields and returns 50,000,000 rows. Statistically, this means that the second query will return 250 times more data than the first, and yet may use the same number of API calls. If Salesforce had a "select all field" operator, it would encourage lazy programming, potentially using hundreds of times more resources than necessary.

Note that one tenant can't directly affect another, but instead the aggregate is what's important. If you imagine a highway, it's easy to see if that if there are very few cars on the road, then everyone will get to go the speed they desire and reach their destination on time, but if a large number of huge trucks suddenly came on the highway, then all those trucks, and the smaller cars between, would all have to move slower to avoid accidents as the offramps became congested, causing a slow down for everyone.

To discourage this effect, everyone is forced to specify the fields that they want to use. Yes, there are still people that will try to query all the fields on a table at once, but they will be forced to use API calls to use field describes, and may also be forced to limit their query because of the 20,000 character limit, or the limit on the number of long text fields per query, etc. In other words, we should always try to query exactly the fields we need for optimal performance for our own programs (saving bandwidth, CPU, and memory), but also to be a good neighbor to everyone else.

Also note that virtually every DBA will tell you that you should never use "select * from table" even in other databases, like MySQL, because it will have a similar effect. Salesforce is really just enforcing the best practices that all DBAs and programmers everywhere should use.

1
  • This is why @sfdcfox is everyone's favorite. Top notch explanation. Commented Apr 20, 2018 at 12:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .