Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.