473,385 Members | 1,730 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Possible error in mysql query optimizer ?

We have a complex statement created from a web application which does
not work correctly. During analysis, we could reduce this statement to
the following:

SELECT * FROM table WHERE
((row1>=0 AND row1<=2 AND 1) OR 0) AND row2=1;

"row2=1" is not being computed, we also get results with row2<>1;
When we swap the values of our last "AND" like:

SELECT * FROM table WHERE
row2=1 AND ((row1>=0 AND row1<=2 AND 1) OR 0);

everything works fine, the same when the second OR parameter is "1"
like:

SELECT * FROM table WHERE
((row1>=0 AND row1<=2 AND 1) OR 1) AND row2=1;

Please, don't ask about the strange "... AND 1) OR 1)...", in the
original statement it is not a "1" or "0" but more comparisons, which
in this case evaluate to "1" and "0".

Is there something we do not see or is something wrong with the query
optimizer of mysql? We are using mySQL 4.0.21-nt.

Regards,
Matthias.
Jul 20 '05 #1
0 1885

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: kaptain kernel | last post by:
How does one retrieve the rows in a select statement that DONT match the select. select CarIndex FROM DealerCatalog, BigCatalog WHERE DealerCatalog.CarIndex=BigCatalog.CarIndex finds all the...
5
by: Phillip T. Murphy | last post by:
Well, after half pulling my hair out messing with this, I am thinking it is not possible. I did research and found references to "sub-queries" not possible in MySQL (I am using 4.0.18-32 with PHP...
0
by: Morten Gulbrandsen | last post by:
C:\mysql\bin>mysql -u elmasri -pnavathe company Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 29 to server version: 4.1.0-alpha-max-debug Type...
0
by: Morten Gulbrandsen | last post by:
mysql> USE company; Database changed mysql> mysql> DROP TABLE IF EXISTS EMPLOYEE; -------------- DROP TABLE IF EXISTS EMPLOYEE -------------- Query OK, 0 rows affected (0.00 sec)
0
by: Matthias Horbank | last post by:
We have a complex statement created from a web application which does not work correctly. During analysis, we could reduce this statement to the following: SELECT * FROM table WHERE ((row1>=0...
3
by: Thomas R. Hummel | last post by:
Hi, I was just helping a coworker optimize a query. He had two versions: one which used UNION for each value for which he was tallying results and another query which used GROUP BY. Here is an...
5
by: Boo | last post by:
Can someone explain to me why this simple query will not use an index on the field confirm_date? select * from comments where confirm_date != 0 confirm_date is an integer, and I have a regular...
6
by: tracy | last post by:
I have a complex query (16 table join) that until five days ago took 30 sec to run. It now takes eight hours. I restored a backup of the database from five days ago and the query plans are...
39
by: Mairhtin O'Feannag | last post by:
Hello, I have a client (customer) who asked the question : "Why would I buy and use UDB, when MySql is free?" I had to say I was stunned. I have no experience with MySql, so I was left sort...
1
by: deepu03 | last post by:
Hi All I have the following query to be tuned.. SELECT distinct a.EMPLID ,a.PER_ORG ,a.HIRE_DT ,a.grade
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.