Google Mail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
key not used oncolum of type double...why?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  9 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Follow-up To:
Add Cc | Add Follow-up to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers that you hear
 
profke  
View profile   Translate to Translated (View Original)
 More options 7 Nov, 14:18
Newsgroups: comp.databases.mysql
From: profke <pwieg...@gmail.com>
Date: Sat, 7 Nov 2009 06:18:13 -0800 (PST)
Local: Sat 7 Nov 2009 14:18
Subject: key not used oncolum of type double...why?
Hi everybody,

I have a very simple table, with one field of type double in it. I
want to search for values in this column, so, I indexed it. But MySQL
does not seem to use the index. If I query for a exact value, it does:
ie: where col=5.3435 I get the one record which matches. But if I type
col>5, I get the correct results (obviously!) but the index is no
longer used. As i want to query for values, for instance, between 5
and 6, and I expect a lot of records on this table, and a lot of
queries as well, this is worrisome... How can I get MySQL to use the
index?

Interesting: if I sort the table on the column, it does not use the
index either...

Anybody got any ideas?

thanks!

Paul


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Captain Paralytic  
View profile   Translate to Translated (View Original)
 More options 7 Nov, 14:40
Newsgroups: comp.databases.mysql
From: Captain Paralytic <paul_laut...@yahoo.com>
Date: Sat, 7 Nov 2009 06:40:19 -0800 (PST)
Local: Sat 7 Nov 2009 14:40
Subject: Re: key not used oncolum of type double...why?
On 7 Nov, 14:18, profke <pwieg...@gmail.com> wrote:

What does an explain say?

    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
profke  
View profile   Translate to Translated (View Original)
 More options 7 Nov, 14:46
Newsgroups: comp.databases.mysql
From: profke <pwieg...@gmail.com>
Date: Sat, 7 Nov 2009 06:46:00 -0800 (PST)
Subject: Re: key not used oncolum of type double...why?
On 7 nov, 15:40, Captain Paralytic <paul_laut...@yahoo.com> wrote:

Well, it simply says: possible_keys: null

thanks for answering,

Paul


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Captain Paralytic  
View profile   Translate to Translated (View Original)
 More options 7 Nov, 14:49
Newsgroups: comp.databases.mysql
From: Captain Paralytic <paul_laut...@yahoo.com>
Date: Sat, 7 Nov 2009 06:49:28 -0800 (PST)
Local: Sat 7 Nov 2009 14:49
Subject: Re: key not used oncolum of type double...why?
On 7 Nov, 14:46, profke <pwieg...@gmail.com> wrote:

I don't believe you. If that really is all it says then there is
something seriously wrong.

    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
profke  
View profile   Translate to Translated (View Original)
 More options 7 Nov, 18:08
Newsgroups: comp.databases.mysql
From: profke <pwieg...@gmail.com>
Date: Sat, 7 Nov 2009 10:08:28 -0800 (PST)
Local: Sat 7 Nov 2009 18:08
Subject: Re: key not used oncolum of type double...why?
On 7 nov, 15:49, Captain Paralytic <paul_laut...@yahoo.com> wrote:

On 7 nov, 15:49, Captain Paralytic <paul_laut...@yahoo.com> wrote:

Well, I can give you the whole query, and explain too:

mysql> describe item;
+------------+--------------+------+-----+---------+----------------+
| Field      | Type         | Null | Key | Default | Extra          |
+------------+--------------+------+-----+---------+----------------+
| id         | bigint(20)   | NO   | PRI | NULL    | auto_increment |
| name       | varchar(255) | NO   |     |         |                |
| descripton | longtext     | YES  |     | NULL    |                |
| date_start | date         | YES  |     | NULL    |                |
| date_end   | date         | YES  |     | NULL    |                |
| location   | varchar(255) | YES  |     | NULL    |                |
| lng        | double       | YES  |     | NULL    |                |
| lat        | double       | YES  | MUL | NULL    |                |
| views      | bigint(20)   | YES  |     | NULL    |                |
| user_id    | bigint(20)   | YES  |     | NULL    |                |
| created_at | datetime     | YES  |     | NULL    |                |
| updated_at | datetime     | YES  |     | NULL    |                |
+------------+--------------+------+-----+---------+----------------+

mysql> explain select * from item where lat>50;
+----+-------------+-------+------+-----------------+------+---------
+------+------+-------------+
| id | select_type | table | type | possible_keys   | key  | key_len |
ref  | rows | Extra       |
+----+-------------+-------+------+-----------------+------+---------
+------+------+-------------+
|  1 | SIMPLE      | item  | ALL  | latlng,newindex | NULL | NULL    |
NULL |    8 | Using where |
+----+-------------+-------+------+-----------------+------+---------
+------+------+-------------+
1 row in set (0,00 sec)

so..why doesnt it use the index?

greetings,

Paul


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jerry Stuckle  
View profile   Translate to Translated (View Original)
 More options 7 Nov, 18:27
Newsgroups: comp.databases.mysql
From: Jerry Stuckle <jstuck...@attglobal.net>
Date: Sat, 07 Nov 2009 13:27:25 -0500
Local: Sat 7 Nov 2009 18:27
Subject: Re: key not used oncolum of type double...why?

It is saying it is not using a key - not that possible keys is null, as
you claimed in your previous statement.  These are two entirely
different things.

MySQL will not use an index if it thinks the retrieval will return a
significant portion of the table.  In a case like that, going to the
index and retrieving individual rows based on the index can be slower
than just doing a full table scan.

Now, you've only got 8 rows in your table, which is pretty small.  A
table scan would almost always be faster than access via an index.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Captain Paralytic  
View profile   Translate to Translated (View Original)
 More options 7 Nov, 19:30
Newsgroups: comp.databases.mysql
From: Captain Paralytic <paul_laut...@yahoo.com>
Date: Sat, 7 Nov 2009 11:30:40 -0800 (PST)
Local: Sat 7 Nov 2009 19:30
Subject: Re: key not used oncolum of type double...why?
On 7 Nov, 18:08, profke <pwieg...@gmail.com> wrote:

Well that is so kind of you.

I really don't get people like you. You come here to ask the experts
and when we ask you for the necessary information, you refuse to give
it, instead suggesting that you know better than us!

If you could read the explain output properly and knew how it all
worked, you wouldn't have needed to ask here in the first place.

Jerry has given you the reason, but please in future, help us to help
you by supplying the necessary information.


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
profke  
View profile   Translate to Translated (View Original)
 More options 8 Nov, 05:11
Newsgroups: comp.databases.mysql
From: profke <pwieg...@gmail.com>
Date: Sat, 7 Nov 2009 21:11:34 -0800 (PST)
Local: Sun 8 Nov 2009 05:11
Subject: Re: key not used oncolum of type double...why?
Dear Captain,

> > Well, I can give you the whole query, and explain too:

> Well that is so kind of you.

Sorry, but sarcasm does not really work, in cases like this....

> I really don't get people like you. You come here to ask the experts
> and when we ask you for the necessary information, you refuse to give
> it, instead suggesting that you know better than us!

I'm sorry, but where did I suggest I knew better than you? And I did
not refuse to give any information. Of course, I should have given the
FULL tabledef and expain in the first post, and by any next question I
have, I will. I did not think it would matter, after me trying to
explain the situation. Obviously, I was wrong.

> If you could read the explain output properly and knew how it all
> worked, you wouldn't have needed to ask here in the first place.

> Jerry has given you the reason, but please in future, help us to help
> you by supplying the necessary information.

I will. :-)

Thanks for helping me out.

I draw the conclusion that my query is correct, and my index too, but
that MySQL won't use them because there is too little data in de
table. That is slightly confusing, as this is only a test-dataset at
the moment. However, testing apparently does not work in this way, and
I need to have a large(ish) dataset for MySQL to tell me what it will
be doing under live load.... Lesson learned...

Greetings,

Paul


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Captain Paralytic  
View profile   Translate to Translated (View Original)
 More options 8 Nov, 12:08
Newsgroups: comp.databases.mysql
From: Captain Paralytic <paul_laut...@yahoo.com>
Date: Sun, 8 Nov 2009 04:08:34 -0800 (PST)
Local: Sun 8 Nov 2009 12:08
Subject: Re: key not used oncolum of type double...why?
On 8 Nov, 05:11, profke <pwieg...@gmail.com> wrote:

> Dear Captain,

> > > Well, I can give you the whole query, and explain too:

> > Well that is so kind of you.

> Sorry, but sarcasm does not really work, in cases like this....

> > I really don't get people like you. You come here to ask the experts
> > and when we ask you for the necessary information, you refuse to give
> > it, instead suggesting that you know better than us!

> I'm sorry, but where did I suggest I knew better than you? And I did
> not refuse to give any information.

Well I asked what the explain said and instead of actually telling me
what the explain said, you decided to (mis)interpret what it said and
offer your view instead. Which was why I then pointed out that "If you
could read the explain output properly and knew how it all worked, you
wouldn't have needed to ask here in the first place."

> I draw the conclusion that my query is correct, and my index too, but
> that MySQL won't use them because there is too little data in de
> table. That is slightly confusing, as this is only a test-dataset at
> the moment. However, testing apparently does not work in this way, and
> I need to have a large(ish) dataset for MySQL to tell me what it will
> be doing under live load.... Lesson learned...

MySQL like other RDBMS has an optimiser which tries to make the best
query it can in the current circumstances. That is why there are
statistics and optimise functions. For when it fails to come up with
the best query, there is the ability to force the use of an index.
This is all documented in the manual.

    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google