The forum is here for legacy reasons. No new posts will be created. User registration is disabled! If you have any questions, please email us or check https://www.adultscriptpro.com for more details!
You are not logged in.
Hi,
While testing RC1 and preparing for the packaging, i've come across the following problem (not really a problem right now, but it can be in the future). The current video table is to large (to many columns)
and while the view view pages work perfectly (very fast), the most recent/most popupar, top rated, top favorited, longest, being watch pages (all with pagination) will be slow once you have > 100.000 videos
and a lot of visitors. So here's what i will do:
Current testing example:
mysql> describe SELECT v.video_id, v.title, v.slug, v.rating, v.rated_by, v.duration, v.thumb, v.thumbs, v.total_views, v.add_time, v.ext, v.premium, u.username FROM video AS v LEFT JOIN user AS u ON (u.user_id = v.user_id) WHERE v.status = 1 ORDER BY v.total_views DESC LIMIT 672,28;
+----+-------------+-------+--------+---------------+---------+---------+---------------+------+-----------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+--------+---------------+---------+---------+---------------+------+-----------------------------+
| 1 | SIMPLE | v | ref | status | status | 1 | const | 2252 | Using where; Using filesort |
| 1 | SIMPLE | u | eq_ref | PRIMARY | PRIMARY | 4 | asp.v.user_id | 1 | |
+----+-------------+-------+--------+---------------+---------+---------+---------------+------+-----------------------------+
2 rows in set (0.00 sec)
mysql>
As you can see mysql has to check 2252 (all the rows) in order to actually do the pagination and fetch the videos. So i will split the
video table in more tables.
Final testing example:
mysql> describe SELECT v.video_id, v.duration, u.username FROM video_views AS vv FORCE INDEX (`total_views`) INNER JOIN video AS v ON (v.video_id = vv.video_id AND v.status = 1) INNER JOIN user AS u ON (u.user_id = v.user_id AND u.status = '1') ORDER BY vv.total_views LIMIT 672,28;
+----+-------------+-------+--------+------------------------+-------------+---------+-----------------+------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+--------+------------------------+-------------+---------+-----------------+------+-------------+
| 1 | SIMPLE | vv | index | NULL | total_views | 8 | NULL | 700 | |
| 1 | SIMPLE | v | eq_ref | PRIMARY,user_id,status | PRIMARY | 4 | asp.vv.video_id | 1 | Using where |
| 1 | SIMPLE | u | eq_ref | PRIMARY,status | PRIMARY | 4 | asp.v.user_id | 1 | Using where |
+----+-------------+-------+--------+------------------------+-------------+---------+-----------------+------+-------------+
3 rows in set (0.00 sec)
mysql>
As you can see mysql has to check only 700 (and this can be optimized even better) in order to actually do the pagination and fetch the videos (the FORCE INDEX will not be required once there are more rows, because mysql will apply it automatically).
Adult Scripts: Adult Script Pro - Adult Search Script
Adult Advertising/Traffic: Plug Rush - EXOClick - PopAds
Offline
hmmmm
Offline
Very interesting. I like this.
Offline
Love how you're always finding solutions to problems that don't exist, yet.
Offline
Love how you're always finding solutions to problems that don't exist, yet.
well... technically it already exist! coz he has a customer who has 100,000+ videos already..
lol...
Offline
I have a site with 158468 videos :-)
Adult Scripts: Adult Script Pro - Adult Search Script
Adult Advertising/Traffic: Plug Rush - EXOClick - PopAds
Offline
question is.... are those embedded or real videos?
Offline
embedded, but that doesnt matter from the mysql optimization point of view
Adult Scripts: Adult Script Pro - Adult Search Script
Adult Advertising/Traffic: Plug Rush - EXOClick - PopAds
Offline
true!
hehe
Offline
So i just migrated a site that has > 103000 videos and the Most Rated, Most Popular, Most Downloads are kinda slow, so this optimization needs to happen soon.
Adult Scripts: Adult Script Pro - Adult Search Script
Adult Advertising/Traffic: Plug Rush - EXOClick - PopAds
Offline