bug 2105 : Browsing tags is slow if tags contains many photos

git-svn-id: http://piwigo.org/svn/trunk@8726 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
rvelices
2011-01-17 21:16:42 +00:00
parent b5046a4f94
commit e123585dde
4 changed files with 67 additions and 132 deletions
+1 -25
View File
@@ -231,23 +231,18 @@ SELECT DISTINCT(id)
{
$query .= "\n AND ".$images_where;
}
if (empty($tag_items) or $search['mode']=='AND')
{ // directly use forbidden and order by
$query .= $forbidden.'
$query .= $forbidden.'
'.$conf['order_by'];
}
$items = array_from_query($query, 'id');
}
if ( !empty($tag_items) )
{
$need_permission_check = false;
switch ($search['mode'])
{
case 'AND':
if (empty($search_clause))
{
$need_permission_check = true;
$items = $tag_items;
}
else
@@ -263,27 +258,8 @@ SELECT DISTINCT(id)
$tag_items
)
);
if ( $before_count < count($items) )
{
$need_permission_check = true;
}
break;
}
if ($need_permission_check and count($items) )
{
$query = '
SELECT DISTINCT(id)
FROM '.IMAGES_TABLE.' i
INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id
WHERE id IN ('.implode(',', $items).') '.$forbidden;
if (!empty($images_where))
{
$query .= "\n AND ".$images_where;
}
$query .= '
'.$conf['order_by'];
$items = array_from_query($query, 'id');
}
}
return $items;