473,809 Members | 2,708 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1899

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

Similar topics

12
14065
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 cars in the dealer catalog that are in the bigger distributor catalog. How do I do the opposite in a single sql statement i.e. all the dealer cars
5
4626
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 4). But, not sure if I am breaking that rule or not. Psuedo code of what I am trying to do... <?php $sql = "select * from table1";
0
1193
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 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> select database(); +------------+ | database() | +------------+
0
3049
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
471
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 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:
3
2455
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 aproximation of what they were: Query #1: --------- SELECT 12 AS ,
5
5140
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 index on it. When I use EXPLAIN it shows all 1233 rows being searched with NULL for the possible keys. Thanks for your help.
6
2107
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 completely different for the same exact query. Five days ago the final estimated row count is 1.6M now it is 1.7E+10 OUCH! The amount of data added in those five days is insignificant (percentage wise). I rebuilt all the indexes using DBCC DBREINDEX...
39
8436
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 of stammering and sputtering, and managed to pull out something I heard a couple of years back - that there was no real transaction safety in MySql. In flight transactions could be lost.
1
3097
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
9601
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10637
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10376
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10379
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10115
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7660
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5687
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3014
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.