we can also optimise one negative tag in the same way
This commit is contained in:
parent
b81a95129c
commit
e971d10d41
@ -894,24 +894,26 @@ class Image
|
|||||||
");
|
");
|
||||||
}
|
}
|
||||||
|
|
||||||
// one positive tag sorted by ID - we can fetch this from the
|
// one tag sorted by ID - we can fetch this from the image_tags table,
|
||||||
// image_tags table, and do the offset / limit there, which is
|
// and do the offset / limit there, which is 10x faster than fetching
|
||||||
// 10x faster than fetching all the image_tags and doing the
|
// all the image_tags and doing the offset / limit on the result.
|
||||||
// offset / limit on the result.
|
|
||||||
elseif (
|
elseif (
|
||||||
$positive_tag_count === 1
|
(
|
||||||
&& $negative_tag_count === 0
|
($positive_tag_count === 1 && $negative_tag_count === 0)
|
||||||
|
|| ($positive_tag_count === 0 && $negative_tag_count === 1)
|
||||||
|
)
|
||||||
&& empty($img_conditions)
|
&& empty($img_conditions)
|
||||||
&& $order == "id DESC"
|
&& $order == "id DESC"
|
||||||
&& !is_null($offset)
|
&& !is_null($offset)
|
||||||
&& !is_null($limit)
|
&& !is_null($limit)
|
||||||
) {
|
) {
|
||||||
|
$in = $positive_tag_count === 1 ? "IN" : "NOT IN";
|
||||||
$query = new Querylet("
|
$query = new Querylet("
|
||||||
SELECT images.*
|
SELECT images.*
|
||||||
FROM images INNER JOIN (
|
FROM images INNER JOIN (
|
||||||
SELECT it.image_id
|
SELECT it.image_id
|
||||||
FROM image_tags it
|
FROM image_tags it
|
||||||
WHERE it.tag_id IN (
|
WHERE it.tag_id $in (
|
||||||
SELECT id
|
SELECT id
|
||||||
FROM tags
|
FROM tags
|
||||||
WHERE LOWER(tag) LIKE LOWER(:tag)
|
WHERE LOWER(tag) LIKE LOWER(:tag)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user