I added compound index and tried without limit. Result is: 40867 rows fetched 
in o.71s. 

-----Original Message-----
From: [email protected] [mailto:[email protected]] On 
Behalf Of Paul McNett
Sent: Wednesday, October 07, 2009 5:27 PM
To: [email protected]
Subject: Re: MySql query speed

Ali İhsan Türkoğlu wrote:
> I am new on MySql.
> 
> I run the below query in MySql Query Browse. Althought I wait more than 10
> minutes, not reached the result.
> 
> Please help what is wrong with my guery. 
> 
>  
> 
> select k.*,  b.sgk_statu
> 
> from kabul_cikis k, basvuru b
> 
> where k.basvuru_fk = b.id
> 
> and k.sosguvsnf = 1
> 
> and k.iptal < 1
> 
> and b.id between 1 and 50655
> 
> and b.id in( select basvuru_fk from kabul_cikis where iptal < 1 group by
> basvuru_fk having MIN(cikis_zmn)> ' ')
> 
> and k.devrkurum <> '4';



Try this one that doesn't get all fields, that puts the join in a join clause, 
(temporarily) does away with the subquery, and adds a limit clause, and see if 
it 
performs better:

select k.iptal,
        k.sosguvsnf,
        k.devrkurum,
        b.sgk_statu
   from kabul_cikis k
  inner join basvuru b
     on b.id = k.basvuru_fk
  where k.sosguvsnf = 1
    and k.iptal < 1
    and b.id between 1 and 50665
    and k.devrkurum <> '4'
  limit 1000;

If this one still takes forever, you need to look at your indexes. If this one 
performs quickly, start adding back the things I took away to find out where 
the 
bottleneck is. If there are a ton of fields coming over a slow net for over 50K 
records, that will definitely slow it down. Perhaps it is the subquery.

HTH
Paul


[excessive quoting removed by server]

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/000101ca475e$de9a6a00$9bcf3e...@com
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to