optimizing count statement
Posted by:
Karolis
Date: October 11, 2005 11:30AM
hello,
I am working on a search engine PHP script and I have a problem with select count(*) performance:
The table I am working on has 2 columns:
KeywordID (int), DocumentID(int);
I have created indexes for both of those columns.
My SQL statement is as follows:
SELECT COUNT(*) AS Cnt FROM TABLE T1, TABLE T2 WHERE (T1.KeywordID = 7 AND T2.KeywordID = 79 ) AND (T1.DocumentID = T2.DocumentID );
Problem:
when MySQL finds no more than ~3000 results, the query is executed in ~0.01 seconds with about 1 million items in the table. However, when there is more than 4000 results found, the query takes about 2 seconds to execute.
Is there any way to optimize this selecting this count?
thanks,
Karolis
Subject
Views
Written By
Posted
optimizing count statement
4211
October 11, 2005 11:30AM
1977
October 12, 2005 04:56AM
1892
October 12, 2005 06:31AM
1554
October 12, 2005 07:11AM
1780
October 12, 2005 07:40AM
1694
October 12, 2005 07:53AM
1867
October 12, 2005 07:50AM
1842
October 12, 2005 08:01AM
1814
October 12, 2005 08:05AM
1566
October 12, 2005 08:23AM
1840
October 12, 2005 08:22AM
1795
October 12, 2005 08:38AM
1924
October 12, 2005 08:46AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.