Re: Database design - help

2009-09-05 Thread BobSharp
Thanks

Not sure how I'm reading this,   but shouldn't the URL be linked to SubCategory 
?


  - Original Message -
  From: Martin Gainty
  To: bobsh...@ntlworld.com ; mysql@lists.mysql.com
  Cc: john.l.me...@gmail.com
  Sent: Friday, September 04, 2009 6:09 PM
  Subject: RE: Database design - help


   given the following table layouts

 URLs: URL_ID (primary key for URL) URL_TEXT URL_CATEGORY URL_ID   
 (key which points to URL.URL_ID) CATEGORY_ID  (key which points to 
 CATEGORY.CATEGORY_ID) SUBCATEGORY_ID PK: (URL_ID, CATEGORY_ID) CATEGORY 
 CATEGORY_ID (primary Key for Category) CATEGORY_TEXT SUBCAT SUBCAT_ID
 (concatenated key for SubCat) CATEGORY_ID  (concatenated key for Subcat) 
 SUBCAT_TEXTso the diagram would look something like like 
URL_CATEGORY Table (URL Table)   (CATEGORY TABLE)
 URL_ID1-1 URL.URL_ID 
 CATEGORY.CATEGORY_ID1---1CATEGORY_IDURL_TEXT  1  
↓
  1
  SUBCAT.CATEGORY_ID
  SUBCAT.SUBCAT_TEXT

  this is labour-intensive work that every DBA must perform to create a Database
  Martin Gainty
  __
  Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité


  Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger 
sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung 
oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem 
Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. 
Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung 
fuer den Inhalt uebernehmen.

Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le 
destinataire prévu, nous te demandons avec bonté que pour satisfaire informez 
l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est 
interdite. Ce message sert à l'information seulement et n'aura pas n'importe 
quel effet légalement obligatoire. Étant donné que les email peuvent facilement 
être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité 
pour le contenu fourni.




   From: bobsh...@ntlworld.com
   To: mysql@lists.mysql.com
   CC: john.l.me...@gmail.com
   Subject: Re: Database design - help
   Date: Fri, 4 Sep 2009 16:24:22 +0100
  
   Hi
  
   Thanks for all the responses. However I am still stuck for a MySQL db I
   can create
   and code in PHP. Attached is a brief example of data to be used.
  
   One problem I have is with providing a listing that includes ...
   WTBC (Category without SubCats) and the 3 Zones (also, Cats without
   SubCats ??? )
   (This is for a complete WTBC listing, in practice it may list depending on
   selected Zone)
  
  
   The example Schema is interesting, but is there another way of storing all
   links
   in one table and join them to Category and SubCat tables ?
   An example of the ER Diagram would also be helpful to me.
  
  
   cheers
  
  
  
  
  
   - Original Message -
   From: John Meyer john.l.me...@gmail.com
   To: BobSharp bobsh...@ntlworld.com
   Cc: mysql@lists.mysql.com
   Sent: Monday, August 31, 2009 4:56 PM
   Subject: Re: Database design - help
  
  
BobSharp wrote:
As a complete newbie in MySQL, I need a database
to store URLs related to Tenpin Bowling.
   
There are several Categories ... Equipment Manufacturers,
Organistations, (UK) ProShops, (UK) Bowling Centres, Personal
Websites, Misc., Coaching  Instructional websites, etc.
   
There will be some sub-categories.
eg: Organistions will have ... Zones of WTBC, National Organisations
within
the Zones, UK organisations, Disabled Bowling organisations, ...
eg: Personal Website might have ... Bowler's, Pro Bowler's, Leagues,
etc.
   
Can anyone suggest how I should set out tables for this database ?
   
   
Here's one suggestion
   
Table:
   
URLs:
URL_ID
URL_TEXT
   
CATEGORY
CATEGORY_ID
CATEGORY_TEXT
   
SUBCAT
SUBCAT_ID
CATEGORY_ID
SUBCAT_TEXT
   
URL_CATEGORY
URL_ID
CATEGORY_ID
SUBCATEGORY_ID
PK: (URL_ID, CATEGORY_ID)
  
  
   

  
  
  
   No virus found in this incoming message.
   Checked by AVG - www.avg.com
   Version: 8.5.409 / Virus Database: 270.13.72/2337 - Release Date: 08/31/09
   05:50:00
  
  
   --
   I am using the free version of SPAMfighter.
   We are a community of 6 million users fighting spam.
   SPAMfighter has removed 13901 of my spam emails to date.
   Get the free SPAMfighter here: http://www.spamfighter.com/len
  
   The Professional version does not have this message
  


--
  Windows Live: Keep your friends up to date with what you do online. Find out 
more.



warning and error when I install the db

2009-09-05 Thread Gabriele Giorelli
Hi, 

After installing mysql-5.1.37 on solaris10, I am getting this message: 

../mysql_install_db --user=mysql --ldata=/sqldata 
Installing MySQL system tables... 
090905 13:10:19 [Warning] option 'max_join_size': unsigned value 
184467440737095 
51615 adjusted to 4294967295 
090905 13:10:19 [Warning] option 'max_join_size': unsigned value 
184467440737095 
51615 adjusted to 4294967295 
090905 13:10:19 [ERROR] /usr/local/mysql5/libexec/mysqld: unknown variable 
'tabl 
e_open_cache=64' 
Installation of system tables failed! 

Examine the logs in /sqldata for more information. 
You can try to start the mysqld daemon with: 
/usr/local/mysql5/libexec/mysqld --skip-grant  
and use the command line tool 
/usr/local/mysql5/bin/mysql to connect to the mysql 
database and look at the grant tables: 

shell /usr/local/mysql5/bin/mysql -u root mysql 
mysql show tables 

Try 'mysqld --help' if you have problems with paths. Using --log 
gives you a log in /sqldata that may be helpful. 

The latest information about MySQL is available on the web at 
http://www.mysql.com 
Please consult the MySQL manual section: 'Problems running mysql_install_db', 
and the manual section that describes problems on your OS. 
Another information source is the MySQL email archive. 
Please check all of the above before mailing us! 
And if you do mail us, you MUST use the /usr/local/mysql5/bin/mysqlbug script! 
-bash-3.00# Broken Pipe 


I also tried this: 

/usr/local/mysql5/libexec/mysqld --skip-grant  
[1] 23145 
-bash-3.00# 090905 13:17:49 [Warning] option 'max_join_size': unsigned value 
18446744073709551615 adjusted to 4294967295 
090905 13:17:49 [Warning] option 'max_join_size': unsigned value 
18446744073709551615 adjusted to 4294967295 
090905 13:17:49 [ERROR] /usr/local/mysql5/libexec/mysqld: unknown variable 
'table_open_cache=64'


Could you please advise?
thank you
GG


  


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org



RE: 1 Machine with 4 GB RAM for Big Size MySQL Data Size

2009-09-05 Thread Andrew Braithwaite
One word: Backups!

If your potential client must restrict you to one server then your
primary consideration in this design must be backups, this cannot be
stressed enough.

One server with 4GB main memory should be fine for your 24GB database
with small monthly growth and low number of users, you should be fine
using InnoDB with the default settings or perhaps some my.cnf tuning for
your particular needs (look at the www.mysqlperformanceblog.com archives
for some tips on that).

But you absolutely must consider backups, if they already have a backup
server then look at using the free version of zmanda or some other
backup scripts.  If not then you could consider using Amazon S3 as a
backup solution, it's easy to use and quite cheap too.

Cheers,

Andrew

-Original Message-
From: Colin Streicher [mailto:co...@obviouslymalicious.com] 
Sent: 05 September 2009 05:16
To: mysql@lists.mysql.com
Subject: Re: 1 Machine with 4 GB RAM for Big Size MySQL Data Size

On Friday 04 September 2009 08:15:35 pm muhammad subair wrote:
 On Sat, Sep 5, 2009 at 5:10 AM, mos mo...@fastmail.fm wrote:
  At 11:48 AM 9/4/2009, you wrote:
  One of my potential clients want to migrate their application to
web
  based (PHP  MySQL), estimates of the data size is 24GB and growth
per
  month is 20MB of data.  Unfortunately, they could only use 1 sever
  machine with 4GB RAM.
 
  The application used in intranet, just running simple transactions
and
  the number of users concurent is under 10.
 
  I need information and suggestion about this condition, whether the
  effort spent on implementation and future maintenance is not too
large
  for use MySQL with this condition?
 
  *btw sorry for my English*
 
  Thanks you very much,
  --
  Muhammad Subair
 
  Muhammad,
  It will depend on your queries and how efficiently you write
them. A
  poorly constructed query on a 24MB table will perform worse than an
  optimized query on a 24GB table.  If you can show us your table
structure
  and query example, (are you joining tables?), then we can guestimate
  better.
 
  Mike
 
  --
 
 Thank you for the feedback and input from all friends.
 
 Currently I have yet enter the design phase, just survey phase to get
the
 information about the data which will migrate from the legacy
application.
 Fyi, the input data which will migrate to MySQL is txt and not normal
for
 Relational Database.
 
 Based on existing feedbacks, I conclude that this project makes sense
and
 can be continued. Perhaps with a note of the problem in vailure single
  point because there is only 1 server.
 
 Furthermore if there is progress again, I'll try sharing.
 
 Thank you very much
 
Perhaps its worth looking at a master-slave relationship between 2
servers if 
you are concerned about a single point of failure.

Colin
-- 
There is a 20% chance of tomorrow.

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:
http://lists.mysql.com/mysql?unsub=andrew.braithwa...@lovefilm.com


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org



Re: 1 Machine with 4 GB RAM for Big Size MySQL Data Size

2009-09-05 Thread muhammad subair
Thanks you all, I will consider all the suggestion, and I will communicate
with the client. You all are so kind :)

On Sat, Sep 5, 2009 at 6:55 PM, Andrew Braithwaite 
andrew.braithwa...@lovefilm.com wrote:

 One word: Backups!

 If your potential client must restrict you to one server then your
 primary consideration in this design must be backups, this cannot be
 stressed enough.

 One server with 4GB main memory should be fine for your 24GB database
 with small monthly growth and low number of users, you should be fine
 using InnoDB with the default settings or perhaps some my.cnf tuning for
 your particular needs (look at the www.mysqlperformanceblog.com archives
 for some tips on that).

 But you absolutely must consider backups, if they already have a backup
 server then look at using the free version of zmanda or some other
 backup scripts.  If not then you could consider using Amazon S3 as a
 backup solution, it's easy to use and quite cheap too.

 Cheers,

 Andrew

 -Original Message-
 From: Colin Streicher [mailto:co...@obviouslymalicious.com]
 Sent: 05 September 2009 05:16
 To: mysql@lists.mysql.com
 Subject: Re: 1 Machine with 4 GB RAM for Big Size MySQL Data Size

 On Friday 04 September 2009 08:15:35 pm muhammad subair wrote:
  On Sat, Sep 5, 2009 at 5:10 AM, mos mo...@fastmail.fm wrote:
   At 11:48 AM 9/4/2009, you wrote:
   One of my potential clients want to migrate their application to
 web
   based (PHP  MySQL), estimates of the data size is 24GB and growth
 per
   month is 20MB of data.  Unfortunately, they could only use 1 sever
   machine with 4GB RAM.
  
   The application used in intranet, just running simple transactions
 and
   the number of users concurent is under 10.
  
   I need information and suggestion about this condition, whether the
   effort spent on implementation and future maintenance is not too
 large
   for use MySQL with this condition?
  
   *btw sorry for my English*
  
   Thanks you very much,
   --
   Muhammad Subair
  
   Muhammad,
   It will depend on your queries and how efficiently you write
 them. A
   poorly constructed query on a 24MB table will perform worse than an
   optimized query on a 24GB table.  If you can show us your table
 structure
   and query example, (are you joining tables?), then we can guestimate
   better.
  
   Mike
  
   --
 
  Thank you for the feedback and input from all friends.
 
  Currently I have yet enter the design phase, just survey phase to get
 the
  information about the data which will migrate from the legacy
 application.
  Fyi, the input data which will migrate to MySQL is txt and not normal
 for
  Relational Database.
 
  Based on existing feedbacks, I conclude that this project makes sense
 and
  can be continued. Perhaps with a note of the problem in vailure single
   point because there is only 1 server.
 
  Furthermore if there is progress again, I'll try sharing.
 
  Thank you very much
 
 Perhaps its worth looking at a master-slave relationship between 2
 servers if
 you are concerned about a single point of failure.

 Colin
 --
 There is a 20% chance of tomorrow.

 --
 MySQL General Mailing List
 For list archives: http://lists.mysql.com/mysql
 To unsubscribe:
 http://lists.mysql.com/mysql?unsub=andrew.braithwa...@lovefilm.com


 --
 MySQL General Mailing List
 For list archives: http://lists.mysql.com/mysql
 To unsubscribe:http://lists.mysql.com/mysql?unsub=msub...@gmail.com




-- 
Muhammad Subair


Re: Database design - help

2009-09-05 Thread BobSharp
Please forgive my total ignorance.

URL-Category  linking   ...   with  Foriegn Keys  or  Primary Keys ?

Have been trying to create the ER Diagram with  MySQL Workbench,
and getting very frustrated.


cheers




  - Original Message -
  From: Martin Gainty
  To: bobsh...@ntlworld.com ; mysql@lists.mysql.com
  Cc: john.l.me...@gmail.com
  Sent: Friday, September 04, 2009 6:09 PM
  Subject: RE: Database design - help


   given the following table layouts

 URLs: URL_ID (primary key for URL) URL_TEXT URL_CATEGORY URL_ID   
 (key which points to URL.URL_ID) CATEGORY_ID  (key which points to 
 CATEGORY.CATEGORY_ID) SUBCATEGORY_ID PK: (URL_ID, CATEGORY_ID) CATEGORY 
 CATEGORY_ID (primary Key for Category) CATEGORY_TEXT SUBCAT SUBCAT_ID
 (concatenated key for SubCat) CATEGORY_ID  (concatenated key for Subcat) 
 SUBCAT_TEXTso the diagram would look something like like 
URL_CATEGORY Table (URL Table)   (CATEGORY TABLE)
 URL_ID1-1 URL.URL_ID 
 CATEGORY.CATEGORY_ID1---1CATEGORY_IDURL_TEXT  1  
↓
  1
  SUBCAT.CATEGORY_ID
  SUBCAT.SUBCAT_TEXT

  this is labour-intensive work that every DBA must perform to create a Database
  Martin Gainty
  __

   From: bobsh...@ntlworld.com
   To: mysql@lists.mysql.com
   CC: john.l.me...@gmail.com
   Subject: Re: Database design - help
   Date: Fri, 4 Sep 2009 16:24:22 +0100
  
   Hi
  
   Thanks for all the responses. However I am still stuck for a MySQL db I
   can create
   and code in PHP. Attached is a brief example of data to be used.
  
   One problem I have is with providing a listing that includes ...
   WTBC (Category without SubCats) and the 3 Zones (also, Cats without
   SubCats ??? )
   (This is for a complete WTBC listing, in practice it may list depending on
   selected Zone)
  
  
   The example Schema is interesting, but is there another way of storing all
   links
   in one table and join them to Category and SubCat tables ?
   An example of the ER Diagram would also be helpful to me.
  
  
   cheers
  
  
  
  

--
I am using the free version of SPAMfighter.
We are a community of 6 million users fighting spam.
SPAMfighter has removed 13901 of my spam emails to date.
Get the free SPAMfighter here: http://www.spamfighter.com/len

The Professional version does not have this message


How to optimize a slow query?

2009-09-05 Thread Jia Chen

Hi there,

One simple query took more than 10 minutes.  Here is how relevant rows 
in the slow query log looks like:


# Time: 090905 10:49:57
# u...@host: root[root] @ localhost []
# Query_time: 649  Lock_time: 0  Rows_sent: 0  Rows_examined: 26758561
use world;
create table rmpdata1 select ri.*,
mv.MV, coalesce(ri.code,mv.code) as ccode,
coalesce(ri.ndate,mv.ndate) as cndate
from RItime as ri left outer join
MVtime as mv
on (ri.code=mv.code and
ri.ndate=mv.ndate);

When I explain only the select clause, I get
+--+---+
| id | select_type | table | type   | possible_keys | key | key_len 
| ref  | rows | Extra |

++-+---++---+-+-+--+--+---+
|  1 | SIMPLE  | ri| ALL| NULL  | NULL| NULL
| NULL | 13419851 |   |
|  1 | SIMPLE  | mv| eq_ref | PRIMARY   | PRIMARY | 11  
| world.ri.code,world.ri.ndate |1 |   |

++-+---++---+-+-+--+--+---+
2 rows in set (0.00 sec)

I use show table status from world; to get information about two 
tables, RItime and MVtime, in the join clause:

  Name: RItime
Engine: MyISAM
   Version: 10
Row_format: Dynamic
  Rows: 13419851
Avg_row_length: 31
   Data_length: 427721848
Max_data_length: 281474976710655
  Index_length: 347497472
 Data_free: 0
Auto_increment: NULL
   Create_time: 2009-09-03 10:17:57
   Update_time: 2009-09-03 12:04:02
Check_time: NULL
 Collation: latin1_swedish_ci
  Checksum: NULL
Create_options:
   Comment:
*** 2. row ***
  Name: MVtime
Engine: MyISAM
   Version: 10
Row_format: Dynamic
  Rows: 13562373
Avg_row_length: 31
   Data_length: 430220056
Max_data_length: 281474976710655
  Index_length: 350996480
 Data_free: 0
Auto_increment: NULL
   Create_time: 2009-09-03 13:31:33
   Update_time: 2009-09-03 13:43:51
Check_time: NULL
 Collation: latin1_swedish_ci
  Checksum: NULL
Create_options:
   Comment:

I also describe these two tables:
mysql desc RItime;
+---++--+-++---+
| Field | Type   | Null | Key | Default| Extra |
+---++--+-++---+
| code  | varchar(6) | NO   | PRI ||   |
| ndate | date   | NO   | PRI | -00-00 |   |
| ri| double | YES  | | NULL   |   |
| time  | date   | YES  | | NULL   |   |
| bdate | date   | YES  | | NULL   |   |
+---++--+-++---+
5 rows in set (0.00 sec)

mysql desc MVtime;
+---++--+-++---+
| Field | Type   | Null | Key | Default| Extra |
+---++--+-++---+
| code  | varchar(6) | NO   | PRI ||   |
| ndate | date   | NO   | PRI | -00-00 |   |
| MV| double | YES  | | NULL   |   |
| time  | date   | YES  | | NULL   |   |
| bdate | date   | YES  | | NULL   |   |
+---++--+-++---+
5 rows in set (0.00 sec)

Could you give me some hint on how to improve the speed of this query?  
Thanks.


Best,
Jia




--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org



MAC OS 10.6 Snow Leopard Breaks MySQL - Resolved

2009-09-05 Thread Hagen
I tried creating a soft link to the /usr/local/bin/mysql but that didn't
address the issues I was having. However, following a little more research I
found a discussion of this problem at:

http://stackoverflow.com/questions/1334272/cant-start-mysql-in-mac-os-10-6-s
now-leopard

which said:

YOU MUST REINSTALL mySQL after upgrading to Snow Leopard and remove any
previous versions as well as previous startup from the preference panel.
install 86_64 10.5...I find the others did not work for me.

Bummer.

However, there was also a discussion suggesting the use of MacPorts:

Have you considered installing MacPorts 1.8.0 (release candidate), and
keeping MySQL up-to-date that way? That will build MySQL for the
architecture and OS that you're using, rather than installing a 10.5 version
on 10.6.

I installed MacPorts http://www.macports.org/ (had to reboot) and ran the
following commands:

sudo port -v self update

sudo port list

sudo port install mysql5

The MacPort script reinstalled mysql 5 on my Mac and mysql came up properly
apparently with everything where it belonged. Pretty slick and almost
effortless.


Hagen



-Original Message-
From: Hagen [mailto:finha...@comcast.net] 
Sent: Friday, September 04, 2009 12:24 PM
To: mysql@lists.mysql.com
Subject: RE: MAC OS 10.6 Snow Leopard Breaks MySQL

I don't appear to have a /etc/my.cnf file - could the upgrade have removed
it?

Here is the error string I get when I try and start MySQL:

finhagens-macbook-pro:bin finhagen$ ./mysqld 
[1] 4697

finhagens-macbook-pro:bin finhagen$ 

090904 10:25:18 [ERROR] Can't find messagefile
'/usr/local/mysql/share/english/errmsg.sys'
090904 10:25:18 [Warning] Can't create test file
/usr/local/mysql/data/finhagens-macbook-pro.lower-test
090904 10:25:18 [Warning] Can't create test file
/usr/local/mysql/data/finhagens-macbook-pro.lower-test
./mysqld: Can't change dir to '/usr/local/mysql/data/' (Errcode: 2)
090904 10:25:18 [ERROR] Aborting

I have noted that a new path was created for mysql during the upgrade:
 
/usr/local/mysql-5.1.31-osx10.5-86/ ...bin ...share ...data etc.

Obviously that new path is resulting in the errors above. 

-What's the best way to inform MySQL the direct structure changed?

-Is there a 5.4 version for MAC OS 10.6? 

-Would it make sense to reinstall with that version? (my data base
is tiny and its relatively easy to export and import it and I am the only
user)


Hagen




-Original Message-

Sent: Friday, September 04, 2009 11:03 AM
To: Hagen
Subject: RE: MAC OS 10.6 Snow Leopard Breaks MySQL

What is the connect string in the /etc/my.cnf file?

-Original Message-
From: Hagen [mailto:finha...@comcast.net] 
Sent: Friday, September 04, 2009 9:45 AM
To: mysql@lists.mysql.com
Subject: MAC OS 10.6 Snow Leopard Breaks MySQL

I upgraded to MAC OS 10.6 Snow Leopard over the weekend and now I find
that
upgrade appears to have broken MySQL (5.1.31 MySQL Community Server
(GPL)).
When I attempt to start MySQL I get:

ERROR 2002: (HY000): Can't connect to local MySQL server through socket
'/tmp/mysql.sock (2)

Has anyone else had this issue and do you know of a fix or work around?

Hagen Finley
Boulder, CO


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:
http://lists.mysql.com/mysql?unsub=jgor...@westernwats.com


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=finha...@comcast.net


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org



Re: How to optimize a slow query?

2009-09-05 Thread mos
How many rows were added to rmpdata1 table? If it is 13.4 million rows then 
it is going to take several minutes to join this many rows from the 2 tables.
Is there a 1:1 relationship between the two tables or a 1:Many? If there is 
a 1:1 then I'd recommend joining the two tables into 1 table so you don't 
have to join them in the first place.
The only other thing I can suggest is to change the type of index on the 
tables being joined to see if that makes a speed difference. For example, 
if you are using BTREE then switch to HASH or vice versa. See 
http://dev.mysql.com/doc/refman/5.0/en/create-index.html for more info.


Mike

At 10:05 AM 9/5/2009, Jia Chen wrote:

Hi there,

One simple query took more than 10 minutes.  Here is how relevant rows in 
the slow query log looks like:


# Time: 090905 10:49:57
# u...@host: root[root] @ localhost []
# Query_time: 649  Lock_time: 0  Rows_sent: 0  Rows_examined: 26758561
use world;
create table rmpdata1 select ri.*,
mv.MV, coalesce(ri.code,mv.code) as ccode,
coalesce(ri.ndate,mv.ndate) as cndate
from RItime as ri left outer join
MVtime as mv
on (ri.code=mv.code and
ri.ndate=mv.ndate);

When I explain only the select clause, I get
+--+---+
| id | select_type | table | type   | possible_keys | key | key_len | 
ref  | rows | Extra |

++-+---++---+-+-+--+--+---+
|  1 | SIMPLE  | ri| ALL| NULL  | NULL| NULL
| NULL | 13419851 |   |
|  1 | SIMPLE  | mv| eq_ref | PRIMARY   | PRIMARY | 11
| world.ri.code,world.ri.ndate |1 |   |
++-+---++---+-+-+--+--+---+
2 rows in set (0.00 sec)

I use show table status from world; to get information about two tables, 
RItime and MVtime, in the join clause:

  Name: RItime
Engine: MyISAM
   Version: 10
Row_format: Dynamic
  Rows: 13419851
Avg_row_length: 31
   Data_length: 427721848
Max_data_length: 281474976710655
  Index_length: 347497472
 Data_free: 0
Auto_increment: NULL
   Create_time: 2009-09-03 10:17:57
   Update_time: 2009-09-03 12:04:02
Check_time: NULL
 Collation: latin1_swedish_ci
  Checksum: NULL
Create_options:
   Comment:
*** 2. row ***
  Name: MVtime
Engine: MyISAM
   Version: 10
Row_format: Dynamic
  Rows: 13562373
Avg_row_length: 31
   Data_length: 430220056
Max_data_length: 281474976710655
  Index_length: 350996480
 Data_free: 0
Auto_increment: NULL
   Create_time: 2009-09-03 13:31:33
   Update_time: 2009-09-03 13:43:51
Check_time: NULL
 Collation: latin1_swedish_ci
  Checksum: NULL
Create_options:
   Comment:

I also describe these two tables:
mysql desc RItime;
+---++--+-++---+
| Field | Type   | Null | Key | Default| Extra |
+---++--+-++---+
| code  | varchar(6) | NO   | PRI ||   |
| ndate | date   | NO   | PRI | -00-00 |   |
| ri| double | YES  | | NULL   |   |
| time  | date   | YES  | | NULL   |   |
| bdate | date   | YES  | | NULL   |   |
+---++--+-++---+
5 rows in set (0.00 sec)

mysql desc MVtime;
+---++--+-++---+
| Field | Type   | Null | Key | Default| Extra |
+---++--+-++---+
| code  | varchar(6) | NO   | PRI ||   |
| ndate | date   | NO   | PRI | -00-00 |   |
| MV| double | YES  | | NULL   |   |
| time  | date   | YES  | | NULL   |   |
| bdate | date   | YES  | | NULL   |   |
+---++--+-++---+
5 rows in set (0.00 sec)

Could you give me some hint on how to improve the speed of this query?
Thanks.

Best,
Jia




--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=mo...@fastmail.fm



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org