Bad MySQL performance with LEFT JOINS in combination with BIGINT(16) Keys

2005-09-21 Thread Christofer Dutz
Hi, I just ran into a very strange problem. I have two simple tables with BIGINT(16) PKs. The primary table has 7500 records and the secondars has 15000. If I execute: SELECT * FROM lad JOIN snd ON lad.id = snd.lad_id The query takes 8 seconds. If I execute this one: SELECT * FROM lad LEFT

Re: Bad MySQL performance with LEFT JOINS in combination with BIGINT(16) Keys

2005-09-21 Thread Devananda
Christofer Dutz wrote: Hi, I just ran into a very strange problem. I have two simple tables with BIGINT(16) PKs. The primary table has 7500 records and the secondars has 15000. If I execute: SELECT * FROM lad JOIN snd ON lad.id = snd.lad_id The query takes 8 seconds. If I execute this one:

Re: Bad MySQL performance with LEFT JOINS in combination with BIGINT(16)Keys

2005-09-21 Thread Christofer Dutz
Ok ... here all the information I could find: CREATE TABLE `disco_lad` ( `id` bigint(16) unsigned NOT NULL auto_increment, `import_datum` date default NULL, `import_zeit` time default NULL, `gst` smallint(4) unsigned default '0', `gst_bez` varchar(40) default NULL, `betrieb`

Re: Bad MySQL performance with LEFT JOINS in combination with BIGINT(16)Keys

2005-09-21 Thread Alexey Polyakov
Looks like you don't have index on `lad_id` field in second table. So when you do the first query, mysql first does a full scan of 2nd table, then does eqref lookup for 1st table, which is rather fast operation. But when you do the left join, it scans first table and for each value of id does a