Jump to content

Impossible WHERE noticed after reading const tables


neoform

Recommended Posts

I realize that mysql says it's useless to be there, but I'm using this as a check to make sure that both those fields are applicable to the row I'm selecting.. 

question is, does this have a negative effect in anyway?

[code]
+----+-------------+-------+------+---------------+-----+---------+-----+------+-----------------------------------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra                                              |
+----+-------------+-------+------+---------------+-----+---------+-----+------+-----------------------------------------------------+
|  1 | SIMPLE      | NULL  | NULL | NULL          | NULL| NULL    | NULL| NULL | Impossible WHERE noticed after reading const tables |
+----+-------------+-------+------+---------------+-----+---------+-----+------+-----------------------------------------------------+
[/code]
Link to comment
Share on other sites

since you asked so nicely.. ;)

[code]
SELECT
id,
url_name,
name,
category,
type,
body,
description,
url,
source,
source_id,
location,
posted_on,
user_id,
votes,
credibility,
misquote 
FROM
seeds
WHERE
category = 'world'
AND
url_name = 'moo'
[/code]

url_name is a unique field (unique index, not primary key), which is why it's probably saying that..
Link to comment
Share on other sites

well i apply the category as more of a qualifier..  basically making sure that the row being selected matches both requirements..  url_name AND category..  i don't want a result being returned if the category does not match that row even if the const field matches..
Link to comment
Share on other sites

  • 1 month later...
Hi,

It *is* something to worry about as it significantly reduces the speed of the query, as no index is used.

What's the solution to this? Let's say I have a column COL1 in my db. This needs to be unique. But in conjunction with COL2, this also needs a separate index. How should I tell MySQL that it's OK to have the two indices and use both of them in queries?

I am using MySQL 4.1.21-standard-l.

Thanks!
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.