Ignore:
Timestamp:
May 3, 2008, 3:52:08 AM (16 years ago)
Author:
rvelices
Message:

just some optimizations (especially for large dbs)

  • replace some REGEXP with LIKE in sql
  • optimized queries for the combination of large data sets with picture_url_style file
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/category_cats.inc.php

    r2299 r2327  
    5555  $query = '
    5656SELECT
    57   id, name, permalink, representative_picture_id, comment, nb_images,
     57  id, name, permalink, representative_picture_id, comment, nb_images, uppercats,
    5858  date_last, max_date_last, count_images, count_categories
    5959  FROM '.CATEGORIES_TABLE.' INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.'
     
    9494    ON ic.category_id = c.id';
    9595    $query.= '
    96   WHERE uppercats REGEXP \'(^|,)'.$row['id'].'(,|$)\'
    97 '.get_sql_condition_FandF
     96  WHERE uppercats LIKE \''.$row['uppercats'].',%\''
     97  .get_sql_condition_FandF
    9898  (
    9999    array
     
    103103        'visible_images' => 'image_id'
    104104      ),
    105     'AND'
     105    "\n  AND"
    106106  ).'
    107107  ORDER BY RAND()
     
    120120  FROM '.CATEGORIES_TABLE.' INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.'
    121121  ON id = cat_id and user_id = '.$user['id'].'
    122   WHERE uppercats REGEXP \'(^|,)'.$row['id'].'(,|$)\'
    123     AND representative_picture_id IS NOT NULL
    124 '.get_sql_condition_FandF
     122  WHERE uppercats LIKE \''.$row['uppercats'].',%\'
     123    AND representative_picture_id IS NOT NULL'
     124  .get_sql_condition_FandF
    125125  (
    126126    array
     
    128128        'visible_categories' => 'id',
    129129      ),
    130     'AND'
     130    "\n  AND"
    131131  ).'
    132132  ORDER BY RAND()
Note: See TracChangeset for help on using the changeset viewer.