Re: a lesson in query writing and (maybe) a bug report

2011-08-28 Thread Jigal van Hemert
Hi, On 28-8-2011 4:08, shawn wilson wrote: On Sat, Aug 27, 2011 at 17:33, Arthur Fuller wrote: I agree 110%. It is completely pointless to index a column with that amount of NULLs. In practical fact I would go further: what is the point of a NULLable column? A NULL 'value' is special in most

Re: a lesson in query writing and (maybe) a bug report

2011-08-27 Thread shawn wilson
On Sat, Aug 27, 2011 at 17:33, Arthur Fuller wrote: > I agree 110%. It is completely pointless to index a column with that amount > of NULLs. In practical fact I would go further: what is the point of a > NULLable column? I try to design my tables such that every column is NOT > NULL. In practice

Re: a lesson in query writing and (maybe) a bug report

2011-08-27 Thread Michael Dykman
It is a general rule that indexes for columns with low cardinality are not worth it, often making queries more expensive than they would be without said index. binary columns all suffer from this. - michael dykman On Sat, Aug 27, 2011 at 4:52 PM, Dave Dyer wrote: > > The "innocuous change" w

Re: a lesson in query writing and (maybe) a bug report

2011-08-27 Thread Arthur Fuller
I agree 110%. It is completely pointless to index a column with that amount of NULLs. In practical fact I would go further: what is the point of a NULLable column? I try to design my tables such that every column is NOT NULL. In practice this is not realistic, but I try to adhere to this principle

Re: a lesson in query writing and (maybe) a bug report

2011-08-27 Thread Jigal van Hemert
Hi, On 27-8-2011 22:52, Dave Dyer wrote: The "innocuous change" was to add an index for "is_robot" which is true for 6 out of 20,000 records and null for the rest. Not useful to add an index for that. I also wonder why the value is null (meaning: unknown, not certain) for almost all records.

a lesson in query writing and (maybe) a bug report

2011-08-27 Thread Dave Dyer
The "innocuous change" was to add an index for "is_robot" which is true for 6 out of 20,000 records and null for the rest. My complaint/question/observation is not how to optimize the query that went awry, but to be alarmed that a venerable and perfectly serviceable query, written years ago and

Re: a lesson in query writing and (maybe) a bug report

2011-08-27 Thread Jigal van Hemert
Hi, On 27-8-2011 1:28, Dave Dyer wrote: Can you post the EXPLAIN EXTENDED output for your before and after queries? also, have you recently run an ANALYZE TABLE on the tables? What was the result of ANALYZE TABLE? What is the engine of the tables involved? // before Used keys: p2.NULL,

a lesson in query writing and (maybe) a bug report

2011-08-26 Thread Dave Dyer
BTW, the query on the database with the added index doesn't take forever, it takes a mere 51 minutes (vs. instantaneous). -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org

a lesson in query writing and (maybe) a bug report

2011-08-26 Thread Dave Dyer
BTW, the query on the database with the added index doesn't take forever, it takes a mere 51 minutes (vs. instantaneous). -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org

Re: Re: a lesson in query writing and (maybe) a bug report

2011-08-26 Thread Dave Dyer
> > >Can you post the EXPLAIN EXTENDED output for your before and after queries? >also, have you recently run an ANALYZE TABLE on the tables? // before mysql> explain extended select p1.player_name,g.score1,g.time1,g.color1,p2.player_name,g.score2,g.time2,g.color2,g.gamename,gmtdate -> f

Re: a lesson in query writing and (maybe) a bug report

2011-08-26 Thread Dan Nelson
In the last episode (Aug 26), Dave Dyer said: > This is a cautionary tale - adding indexes is not always helpful or > harmless. I recently added an index to the "players" table to optimize a > common query, and as a consequence this other query flipped from innocuous > to something that takes infi

a lesson in query writing and (maybe) a bug report

2011-08-26 Thread Dave Dyer
This is a cautionary tale - adding indexes is not always helpful or harmless. I recently added an index to the "players" table to optimize a common query, and as a consequence this other query flipped from innocuous to something that takes infinite time. select p1.player_name,g.score1,g.tim

Re: maybe a bug

2002-06-14 Thread Roger Baklund
* [EMAIL PROTECTED] > In order to remove the first character '0' of the field 'number', > I want to use the following sql query to select the field from my > database. > > select right(number, > if(locate('0',length(number))=1,length(number)-1,length(number))) > as 'no_zero' from mydatabase or

Re: maybe a bug

2002-06-13 Thread Galen Wright-Watson
On Fri, 14 Jun 2002, [GB2312] ³Â׿ wrote: > mysqlmysql 3.23.41 > phpMyAdmin 2.2.3 > os :Linux server 2.4.9-31 > > In order to remove the first character '0' of the field 'number', > I want to use the following sql query to select the field from my database. > > select right(number, >if(locate(

maybe a bug

2002-06-13 Thread 陈卓
mysqlmysql 3.23.41 phpMyAdmin 2.2.3 os :Linux server 2.4.9-31 In order to remove the first character '0' of the field 'number', I want to use the following sql query to select the field from my database. select right(number, if(locate('0',length(number))=1,length(number)-1,length(number))) as '

maybe a bug

2002-06-13 Thread 陈卓
mysqlmysql 3.23.41 phpMyAdmin 2.2.3 os :Linux server 2.4.9-31 In order to remove the first character '0' of the field 'number', I want to use the following sql query to select the field from my database. select right(number, if(locate('0',length(number))=1,length(number)-1,length(number))) as '