Jump to content

Heavily accessed large tables


jaymc

Recommended Posts

What is the best way to deal with heavily acessed large tables

 

When I say large, lets just say you had a table with 5 million rows of data, all of which contain pretty well optimized data

 

With an index yeh sure it only takes 0.8 second to complete a standard query, but this added with other queries combine to make a page take 3+ seconds to load

 

What can one do when faced with a huge table which has relivent data and no redundant to clean out

 

Bit stuck, any ideas/articles which go through combating this problem

Link to comment
https://forums.phpfreaks.com/topic/89355-heavily-accessed-large-tables/
Share on other sites

Ok, the table is 6.7million rows and the query is pretty basic

 

SELECT viewedpro.viewer, viewedpro.time, viewedpro.views, cache.propic as image
        FROM viewedpro
        LEFT JOIN cache ON viewedpro.viewer = cache.username
        WHERE viewedpro.username = 'JMC'
        GROUP BY viewedpro.viewer
        ORDER BY viewedpro.time DESC LIMIT 0,5

 

The execution time is completely dependant on the sheer size of the table rather than the query

 

0.8 seconds is quick for what its doing, but webpages should never really have a noticeable lag therefor I want to try and do something about it

A few things...

 

First, could you post the EXPLAIN output?  Mixing group by/order by will sometimes produce unexpected index usage.

Second, why the LEFT JOIN? You're not doing anything with non-matching records... this can often be slower.

I added the viewer index after I posted the explain, but in the query I gave you an index on the viewer would have had no purpose as it wasnt involved in the Word or any file sorting

 

Regardless, queries still take 0.5 seconds.. combined with other large table queries meaning 3+ seconds for page execution

 

I have to do something with the table.. sooner or later, without flusing out date, just wondering on the common methods to go about this

I added the viewer index after I posted the explain, but in the query I gave you an index on the viewer would have had no purpose as it wasnt involved in the Word or any file sorting

Could you post your SHOW CREATE TABLE? I think we're talking about different things.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.