MySQL query taking too long time to execute [Resolved]

Posted by Thiru under Others on 8/15/2011 | Points: 10 | Views : 3422 | Status : [Member] | Replies : 2
Hi,

I like to get records comparing two tables using mysql query as follows:

select * from tblbf where (rcpt_no not in (select ref_no from tblaccounts))
Note: tblbf is having 20000 records and tblaccounts having 40000 records.
(tblaccounts is not indexed but tblbf is having primary key)

Its taking too long time to show the result.
Any idea to get quick result.?




Responses

Posted by: Nisar87 on: 8/16/2011 [Member] Starter | Points: 50

Up
0
Down

Resolved
20000 or 40000 records are nothing in database, as you mentioned that tblaccouts is not indexed, then I suggest you to index the ref_no column.
[code]
CREATE INDEX ref_no_index ON tblaccouts(ref_no)
[/code]

_______________________________________
Nisar Ahmad
http://www.dotnetobject.com/

Thiru, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Thiru on: 8/16/2011 [Member] Starter | Points: 25

Up
0
Down
Thanks Nisar,
Its working great now.


Thiru, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response