Optimize search

This commit is contained in:
2021-12-28 14:07:25 +03:00
parent 33066414bc
commit a58136c5c2
4 changed files with 13 additions and 9 deletions

View File

@@ -15,8 +15,8 @@ SELECT ARRAY(
) as sml,
(
SELECT count(*) FROM book_authors
LEFT JOIN books ON books.id = book
WHERE author = authors.id AND books.is_deleted = 'f'
LEFT JOIN books ON (books.id = book AND books.is_deleted = 'f')
WHERE author = authors.id
) as books_count
FROM authors
WHERE (
@@ -26,8 +26,8 @@ SELECT ARRAY(
) AND
EXISTS (
SELECT * FROM book_authors
LEFT JOIN books ON books.id = book
WHERE author = authors.id AND books.is_deleted = 'f'
LEFT JOIN books ON (books.id = book AND books.is_deleted = 'f')
WHERE author = authors.id
)
)
SELECT fauthors.id FROM filtered_authors as fauthors