aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorz0rglub <z0rglub@piwigo.org>2004-01-19 21:18:34 +0000
committerz0rglub <z0rglub@piwigo.org>2004-01-19 21:18:34 +0000
commit982bc009b6879ea78d0fd1eec6469c713be2f1dc (patch)
tree791dfa8fc38e5286c19cca894843a4a30f502ed7
parentb81a4dbc62f9746b5861fd2d472b79f8a410c8dd (diff)
Performances improved : replacing the useless LEFT JOIN by INNER JOIN
git-svn-id: http://piwigo.org/svn/branches/release-1_3@301 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--admin/infos_images.php6
-rw-r--r--include/functions_category.inc.php4
-rw-r--r--picture.php14
3 files changed, 14 insertions, 10 deletions
diff --git a/admin/infos_images.php b/admin/infos_images.php
index 59c1126c9..b9d868509 100644
--- a/admin/infos_images.php
+++ b/admin/infos_images.php
@@ -49,7 +49,7 @@ if ( isset( $page['cat'] ) )
$query = 'SELECT id,file';
$query.= ' FROM '.PREFIX_TABLE.'images';
- $query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category ON id = image_id';
+ $query.= ' INNER JOIN '.PREFIX_TABLE.'image_category ON id = image_id';
$query.= ' WHERE category_id = '.$page['cat'];
$query.= ';';
$result = mysql_query( $query );
@@ -176,7 +176,7 @@ if ( isset( $page['cat'] ) )
{
$query = 'SELECT id,keywords';
$query.= ' FROM '.PREFIX_TABLE.'images';
- $query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category ON id = image_id';
+ $query.= ' INNER JOIN '.PREFIX_TABLE.'image_category ON id = image_id';
$query.= ' WHERE category_id = '.$page['cat'];
$query.= ';';
$result = mysql_query( $query );
@@ -279,7 +279,7 @@ if ( count( $errors ) != 0 )
$query = 'SELECT id,file,comment,author,tn_ext,name,date_creation,keywords';
$query.= ',storage_category_id,category_id';
$query.= ' FROM '.PREFIX_TABLE.'images';
- $query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category ON id = image_id';
+ $query.= ' INNER JOIN '.PREFIX_TABLE.'image_category ON id = image_id';
$query.= ' WHERE category_id = '.$page['cat'];
$query.= $conf['order_by'];
$query.= ' LIMIT '.$page['start'].','.$page['nb_image_page'];
diff --git a/include/functions_category.inc.php b/include/functions_category.inc.php
index b46f57ddc..dec7a7bf8 100644
--- a/include/functions_category.inc.php
+++ b/include/functions_category.inc.php
@@ -494,7 +494,7 @@ function initialize_category( $calling_page = 'category' )
$query = 'SELECT COUNT(DISTINCT(id)) AS nb_total_images';
$query.= ' FROM '.PREFIX_TABLE.'images';
- $query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category AS ic';
+ $query.= ' INNER JOIN '.PREFIX_TABLE.'image_category AS ic';
$query.= ' ON id = ic.image_id';
$query.= $page['where'];
$query.= ';';
@@ -528,7 +528,7 @@ function initialize_category( $calling_page = 'category' )
$query = 'SELECT COUNT(DISTINCT(id)) AS nb_total_images';
$query.= ' FROM '.PREFIX_TABLE.'images';
- $query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category AS ic';
+ $query.= ' INNER JOIN '.PREFIX_TABLE.'image_category AS ic';
$query.= ' ON id = ic.image_id';
$query.= $page['where'];
$query.= ';';
diff --git a/picture.php b/picture.php
index de4adb2a3..9430ef538 100644
--- a/picture.php
+++ b/picture.php
@@ -43,7 +43,8 @@ if ( is_numeric( $page['cat'] ) )
$query.= ',category_id';
}
$query.= ' FROM '.PREFIX_TABLE.'images';
-$query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category AS ic ON id = ic.image_id';
+$query.= ' INNER JOIN '.PREFIX_TABLE.'image_category AS ic';
+$query.= ' ON id = ic.image_id';
$query.= $page['where'];
$query.= ' AND id = '.$_GET['image_id'];
$query.= $conf['order_by'];
@@ -77,7 +78,8 @@ $page['storage_category_id'] = $row['storage_category_id'];
// retrieving the number of the picture in its category (in order)
$query = 'SELECT DISTINCT(id)';
$query.= ' FROM '.PREFIX_TABLE.'images';
-$query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category AS ic ON id = ic.image_id';
+$query.= ' INNER JOIN '.PREFIX_TABLE.'image_category AS ic';
+$query.= ' ON id = ic.image_id';
$query.= $page['where'];
$query.= $conf['order_by'];
$query.= ';';
@@ -139,7 +141,7 @@ if ( isset( $_GET['add_fav'] ) )
}
$query = 'SELECT id';
$query.= ' FROM '.PREFIX_TABLE.'images';
- $query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category AS ic';
+ $query.= ' INNER JOIN '.PREFIX_TABLE.'image_category AS ic';
$query.= ' ON id = ic.image_id';
$query.= $page['where'];
$query.= $conf['order_by'];
@@ -168,7 +170,8 @@ if ( $page['num'] < $page['cat_nb_images']-1 )
$next = $page['num'] + 1;
$query = 'SELECT DISTINCT(id),name,file,tn_ext,storage_category_id';
$query.= ' FROM '.PREFIX_TABLE.'images';
- $query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category AS ic ON id=ic.image_id';
+ $query.= ' INNER JOIN '.PREFIX_TABLE.'image_category AS ic';
+ $query.= ' ON id=ic.image_id';
$query.= $page['where'];
$query.= $conf['order_by'];
$query.= ' LIMIT '.$next.',1';
@@ -276,7 +279,8 @@ if ( $page['num'] >= 1 )
$prev = $page['num'] - 1;
$query = 'SELECT DISTINCT(id),name,file,tn_ext,storage_category_id';
$query.= ' FROM '.PREFIX_TABLE.'images';
- $query.= ' LEFT JOIN '.PREFIX_TABLE.'image_category AS ic ON id=ic.image_id';
+ $query.= ' INNER JOIN '.PREFIX_TABLE.'image_category AS ic';
+ $query.= ' ON id=ic.image_id';
$query.= $page['where'];
$query.= $conf['order_by'];
$query.= ' LIMIT '.$prev.',1';