Adult Script Pro Community Forums

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.

#1 2011-04-12 08:49:33

symtab
Administrator
Registered: 2010-08-23
Posts: 7,501
Website

A small optimization that will happen in 1.0 FINAL

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

#2 2011-04-13 11:04:47

pctv
Member
Registered: 2011-03-24
Posts: 34

Re: A small optimization that will happen in 1.0 FINAL

hmmmm

big_smile

Offline

#3 2011-04-13 11:54:56

mfeat50
Member
Registered: 2010-10-25
Posts: 114
Website

Re: A small optimization that will happen in 1.0 FINAL

Very interesting. I like this.

Offline

#4 2011-04-13 12:34:28

Pornogoddess
Member
From: NY
Registered: 2011-01-12
Posts: 183
Website

Re: A small optimization that will happen in 1.0 FINAL

Love how you're always finding solutions to problems that don't exist, yet. smile

Offline

#5 2011-04-13 13:37:41

Eri
Member
Registered: 2011-03-18
Posts: 977

Re: A small optimization that will happen in 1.0 FINAL

nice smile
my site getting slower and slower by the time, when i change to ASP i will not have any problem


Best Adult Affilitate Network:
ExoClick
Best Deals on Dedicated Servers - CDN
INXY

Offline

#6 2011-04-14 05:46:00

pctv
Member
Registered: 2011-03-24
Posts: 34

Re: A small optimization that will happen in 1.0 FINAL

Pornogoddess wrote:

Love how you're always finding solutions to problems that don't exist, yet. smile


well... technically it already exist! coz he has a customer who has 100,000+ videos already..
lol...

big_smile

Offline

#7 2011-04-14 06:54:26

symtab
Administrator
Registered: 2010-08-23
Posts: 7,501
Website

Re: A small optimization that will happen in 1.0 FINAL

I have a site with 158468 videos :-)


Adult Scripts: Adult Script Pro - Adult Search Script
Adult Advertising/Traffic: Plug Rush - EXOClick - PopAds

Offline

#8 2011-04-14 07:06:52

pctv
Member
Registered: 2011-03-24
Posts: 34

Re: A small optimization that will happen in 1.0 FINAL

question is.... are those embedded or real videos? tongue

Offline

#9 2011-04-14 07:08:51

symtab
Administrator
Registered: 2010-08-23
Posts: 7,501
Website

Re: A small optimization that will happen in 1.0 FINAL

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

#10 2011-04-14 07:37:16

pctv
Member
Registered: 2011-03-24
Posts: 34

Re: A small optimization that will happen in 1.0 FINAL

true! tongue

hehe

Offline

#11 2011-04-18 23:04:14

symtab
Administrator
Registered: 2010-08-23
Posts: 7,501
Website

Re: A small optimization that will happen in 1.0 FINAL

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

Board footer

Powered by FluxBB