MySQL slow queries
I have been trying to reduce loading speed of my pages because, apparently mysql server is experiencing some difficulties due to number of queries on the same page!? Frankly, I am not 100% sure that the number of queries is actually causing the slowness with my application, but it's pretty annoying given that the page takes like 8 seconds or something to load.
Now, there is about 11000 records (20mb) in the table, it's definitely not a lot to handle for MYSQL server, however all queries are executed when accessing the page (this is normal of course), pulling data simultaneously from the same table...
Anyway take a look at queries:
------------11000 records------------
<cfquery name="maintable" datasource="datasource">
SELECT *
FROM maintable
WHERE CATEGORY = "1"
ORDER BY DATE DESC , id DESC
</cfquery>
<cfquery name="free" datasource="datasource">
SELECT *
FROM maintable
WHERE buy = "Free" AND CATEGORY = "1"
ORDER BY HITS DESC
</cfquery>
<cfquery name="buy" datasource="datasource">
SELECT *
FROM maintable
WHERE buy = "withprice" AND CATEGORY = "1"
ORDER BY HITS DESC
</cfquery>
------------400 records------------
<cfquery name="news" datasource="datasource">
SELECT *
FROM news
WHERE CATEGORY = "1"
ORDER BY DATE DESC
</cfquery>
------------300 records------------
<cfquery name="tuts" datasource="datasource">
SELECT *
FROM tuts
WHERE CATEGORY = "1"
ORDER BY DATE DESC
</cfquery>
also for now only the primary key is assigned to id/s, but I am thinking on adding one more index for category in the maintable!? On the other hand, this may not be a good idea simply because from 11000 records about 8000 of them are in category 1, so basically queries will have to process about 70+% of all records which can result in even slower loading!?
how to speed things up? guys, I would really appreciate your help on this one.
