Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Boolean Operators (Chicken or the egg type of question) 1

Status
Not open for further replies.

xlhelp

Instructor
Dec 7, 2001
2,976
CA
When running queries (or Searches) is there a difference in speed when using AND followed by OR versus OR followed by AND.

In one of our databases putting an OR seems to cause major pain. Since I am not quite sure of which works better, I thought I would toss the question out to see if someone knows for sure.

My apologies if it's not in right forum, but I am soooo used to this one.

Thanks

A man has only two choices: He can be right or he can be happy.
 

Hi,

Can you post an example of this logic?

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
For example:
Time Entry Type Equal to Billable AND Time Entry Date Between 01/01/2009 and 30/10/2009 AND (Workgroup when time logged Equal to Group 1 OR Workgroup when time logged Equal to Group 3)

takes an enormous amount of time, but

Time Entry Type Equal to Billable AND Time Entry Date Between 01/01/2009 and 30/10/2009 AND Workgroup when time logged Equal to Group 1

Time Entry Type Equal to Billable AND Time Entry Date Between 01/01/2009 and 30/10/2009 AND Workgroup when time logged Equal to Group 3

run separately are done in no time. Haven't yet tried putting an OR between the last two.

The reason for the question is that in the second case, the manager has to put in a lot of time combining the two tables and then manipulating the data.

A man has only two choices: He can be right or he can be happy.
 


How does this run?
Code:
Time Entry Type Equal to Billable AND Time Entry Date Between 01/01/2009 and 30/10/2009 AND Workgroup when time logged IN ('Group 1', 'Group 3')

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Hi, Skip.

Thanks for your help. The query is being run through a proprietary software, as such there is no way to query the groups by separating them with a comma.

I will experiment a few different ways to see if any make sense. If I have success, I will post my results.

A man has only two choices: He can be right or he can be happy.
 
>is there a difference in speed when using AND followed by OR versus OR followed by AND

>The query is being run through a proprietary software

Given the above above, we can't possibly answer that question ...
 
Answered my own qustion. When I ask time entry date between certain dates and time entry type and workgroup type; the query really chugs along slowly since every date is being tested for the time period specified.

But, when I ask for time entry type followed by workgroup and then by a specific time period, the query goes like an Argon filled rocket. The speed improves because each workgroup may not enter time on every day of the specified time period. Funny how this particular proprietary stuff works.

We have changed all our report structure to start with the field that has the least number of variables (not entirely indiscriminately, of course)

Canadian eh! Check out the new social forum Tek-Tips in Canada.
With the state of the world today, monkeys should get grossly insulted when humans claim to be their decendents
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top