Author Topic: Very slow page - mysql and cpu bug  (Read 5361 times)

0 Members and 1 Guest are viewing this topic.

Offline Blackman

  • Pre-Newbie
  • Posts: 3
    • View Profile
Very slow page - mysql and cpu bug
« on: June 17, 2003, 12:11:42 PM »
Hy!

My page is very slow. I create msql log file (slow works):

"# Time: 030616 13:20:18
# User@Host: euronet2002[euronet2002] @ localhost []
# Query_time: 12  Lock_time: 0  Rows_sent: 39537  Rows_examined: 158870
SELECT DISTINCT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits, c.cat_name, u.user_name
            FROM eroticzoneimages i,  eroticzonecategories c
            LEFT JOIN eroticzoneusers u ON (u.user_id = i.user_id)
            WHERE i.image_active = 1 AND i.cat_id NOT IN (0, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 26, 32, 36, 37) AND c.cat_id = i.cat_id
            ORDER BY RAND();"

---------------------

10 users and the gallery slows down.  CPU work = 100% (2.4Ghz P4)
This no correct :(

Please check my site: www.eroticzone.hu

Thx!![/url]

Offline rohanrohanrohan

  • Full Member
  • ***
  • Posts: 200
    • View Profile
Very slow page - mysql and cpu bug
« Reply #1 on: June 17, 2003, 02:08:19 PM »
yep!! initial loading of html is fast. but then takes ages to load the gallery

Offline Jan

  • Administrator
  • 4images Guru
  • *****
  • Posts: 5.024
    • View Profile
    • 4images - Image Gallery Management System
Very slow page - mysql and cpu bug
« Reply #2 on: June 17, 2003, 02:16:37 PM »
Yes, this is an very expensive query because of the RAND() in the ORDER BY clause if you have a lot of images in your database.

Try to change
Code: [Select]
define('SHOW_RANDOM_CAT_IMAGE', 1);
to
Code: [Select]
define('SHOW_RANDOM_CAT_IMAGE', 0);
in includes/constants.php. This disables the category related random image.

If this does not help, change
Code: [Select]
define('SHOW_RANDOM_IMAGE', 1);
to
Code: [Select]
define('SHOW_RANDOM_IMAGE', 0);

This will disable the random image completely.

Jan
Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search

Offline kief24

  • Sr. Member
  • ****
  • Posts: 267
    • View Profile
Re: Very slow page - mysql and cpu bug
« Reply #3 on: April 17, 2006, 10:52:37 AM »
The random image function can be a problem for the speed of the website if you have a lot of images, wright ?
Is it not possible to let the random image function take an image out of 1 category ?
So instead of taking a random image from a collection of 2000 images, it has to take an image fom a category with let's say  50 images.
Is this possible and could this solve the problem ?
So you can keep the random image function, and website will not encounter problems.