17 messages in com.mysql.lists.mysqlRe: Sub Query to long...
FromSent OnAttachments
Dan Bolser24 May 2005 03:08 
mfat...@free.fr24 May 2005 05:56 
SGr...@unimin.com24 May 2005 06:22 
Dan Bolser24 May 2005 06:23 
Michael Stassen24 May 2005 06:38 
Michael Stassen24 May 2005 07:25 
mfat...@free.fr24 May 2005 07:39 
SGr...@unimin.com24 May 2005 07:56 
Dan Bolser24 May 2005 08:44 
Dan Bolser24 May 2005 16:45 
mfat...@free.fr24 May 2005 22:42 
mfat...@free.fr24 May 2005 23:01 
mfat...@free.fr24 May 2005 23:19 
SGr...@unimin.com25 May 2005 06:31 
Hendro Suryawan25 May 2005 12:09 
Hendro Suryawan25 May 2005 15:23 
Hendro Suryawan26 May 2005 08:25 
Subject:Re: Sub Query to long...
From:mfat...@free.fr (mfat@free.fr)
Date:05/24/2005 11:01:07 PM
List:com.mysql.lists.mysql

I rerezad you and discovered that (BrgId, Kode) is UNIQUE. your query will return no rows :o)

spending 54813 ms for nothing.

Mathias

Hi, You may have the same table structure in MS, but not the same table definiton : constraints+indexes+stats !

try : create index toto on Barang(BrgId, Kode, Barang); Select BrgId, Kode, Barang From Barang Group By Barang Having Count(*) > 1 ;

Selon Hendro Suryawan <elc@adetex.co.id>:

Hi, I have 8414 records in table name Barang, I run query like this :

Select BrgId, Kode, Barang From Barang Where Barang in (Select Barang From Barang Group By Barang Having Count(*) > 1 )

and the answer took 54813 ms. I think is too long. I ran the same query against same table in MS SQL Server it took 1 second. Does anyone have any idea?

I have mysql on FC 3 X86_64 on Athlon 64, RAM 512 MB. Table Definition : CREATE TABLE `Barang` ( `BrgId` int(4) NOT NULL default '0', `Kode` varchar(11) NOT NULL default '', `Barang` varchar(70) NOT NULL default '', `Satuan` varchar(10) default NULL, `Stok` decimal(10,0) default NULL, `Nilai` decimal(10,0) default NULL, `Lokal` char(1) default NULL, `SGrupId` int(10) NOT NULL default '0', `StokMin` int(10) default NULL, `Catatan` blob, `Benda` char(1) NOT NULL default '', `Gambar` longblob, `LastTrans` date default NULL, `Operators` varchar(50) default NULL, PRIMARY KEY (`BrgId`), UNIQUE KEY `Kode` (`Kode`), KEY `Barang` (`Barang`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1;

thanks, Hendro