+ Start a Discussion
HaroldHHaroldH 

Query Timeout on Account Name field with 8 "OR" criteria

Speaking of query timeouts, when I run this SOQL query using sforce explorer or any other method that uses the sforce API, I get a timeout:

SELECT Id, Name FROM Account WHERE Name='search text' OR Name='search text' OR Name='search text' OR Name='search text' OR Name='search text' OR Name='search text' OR Name='search text' OR Name='search text' OR Name='search text'

(Assume that each 'search text' is actually a unique value which corresponds to an actual account name in the system.)

The total number of Accounts in the database is 89,514.

If I run an equivalent SOSL search, the response time is very short, as expected.

Is this a problem with something I'm doing, or a performance issue with Salesforce.com?

Thanks.

benjasikbenjasik
Just curious, are you running this as a user with view_all_data? If no, can you try?

There is a known perf issue when doing a bunch of ORs on a name field with a large number of records, and not running as an admin user. Even so, can you log a case so we can track you with the bug we have logged?
HaroldHHaroldH
I am running this with a user with the System Administrator profile.

The slow performance occurs even with a single OR clause.

Examples:

SOQL: Select Id, Name from Account where Name = 'Account'
Elapsed Time: 00:00:00.2100
Returned 2 records.

SOQL: Select Id, Name from Account where Name Like 'Account%'
Elapsed Time: 00:00:00.4700
Returned 78 Records.

SOQL: Select Id, Name from Account where Name = 'Account' or Name = 'Account Variation'
Elapsed Time: 00:00:39.5660
Returned 3 records.

I have logged a case, entitled "Long Query or Timeout with SOQL "SELECT" where NAME = and OR clause" in case you'd like to follow up.

Thanks.