Actions
Bug #14268
closedtwo queries are performed when searching for erratum that does not exist
Description
If you search for something that does not exist (for example, searching for erratum 'asdfasdf' without field specified), two search queries are performed. The first query is to get a count for pagination, but even if the count is zero, the second query is still performed. In some cases, these queries can take 3+ seconds, so running it once instead of twice can make the page much snappier.
To repro, sync some RH repos and then do the following:
time curl -sk 'https://admin:changeme@localhost/katello/api/v2/errata?organization_id=3&search=sadfasdf' > /dev/null
If you enable slow query logging in postgres (log_min_duration_statement = 500 will do it), you'll see two queries:
LOG: duration: 3125.694 ms execute <unnamed>: SELECT COUNT(DISTINCT "katello_errata"."id") FROM "katello_errata" LEFT OUTER JOIN "katello_erratum_cves" ON "katello_erratum_cves"."erratum_id" = "katello_errata"."id" LEFT OUTER JOIN "katello_erratum_bugzillas" ON "katello_erratum_bugzillas"."erratum_id" = "katello_errata"."id" LEFT OUTER JOIN "katello_erratum_packages" ON "katello_erratum_packages"."erratum_id" = "katello_errata"."id" WHERE (("katello_errata"."errata_id" ILIKE '%sadfasdf%' OR "katello_errata"."severity" ILIKE '%sadfasdf%' OR "katello_errata"."errata_type" ILIKE '%sadfasdf%' OR "katello_erratum_cves"."cve_id" ILIKE '%sadfasdf%' OR "katello_erratum_bugzillas"."bug_id" ILIKE '%sadfasdf%' OR "katello_erratum_packages"."nvrea" ILIKE '%sadfasdf%' OR "katello_erratum_packages"."name" ILIKE '%sadfasdf%')) AND "katello_errata"."id" IN (SELECT DISTINCT "katello_errata"."id" FROM "katello_errata" INNER JOIN "katello_repository_errata" ON "katello_repository_errata"."erratum_id" = "katello_errata"."id" WHERE "katello_repository_errata"."repository_id" IN (SELECT "katello_repositories"."id" FROM "katello_repositories" WHERE (katello_repositories.id .... LOG: duration: 3129.778 ms execute <unnamed>: SELECT DISTINCT "katello_errata"."id", katello_errata.updated AS alias_0, katello_errata.id AS alias_1 FROM "katello_errata" LEFT OUTER JOIN "katello_erratum_cves" ON "katello_erratum_cves"."erratum_id" = "katello_errata"."id" LEFT OUTER JOIN "katello_erratum_bugzillas" ON "katello_erratum_bugzillas"."erratum_id" = "katello_errata"."id" LEFT OUTER JOIN "katello_erratum_packages" ON "katello_erratum_packages"."erratum_id" = "katello_errata"."id" WHERE (("katello_errata"."errata_id" ILIKE '%sadfasdf%' OR "katello_errata"."severity" ILIKE '%sadfasdf%' OR "katello_errata"."errata_type" ILIKE '%sadfasdf%' OR "katello_erratum_cves"."cve_id" ILIKE '%sadfasdf%' OR "katello_erratum_bugzillas"."bug_id" ILIKE '%sadfasdf%' OR "katello_erratum_packages"."nvrea" ILIKE '%sadfasdf%' OR "katello_erratum_packages"."name" ILIKE '%sadfasdf%')) AND "katello_errata"."id" IN (SELECT DISTINCT "katello_errata"."id" FROM "katello_errata" INNER JOIN "katello_repository_errata" ON "katello_repository_errata"."erratum_id" = "katello_errata"."id" WHERE "katello_repository_errata"."repository_id" IN (SELECT "katello_repositories"."id" FROM "katello_repositories" WHERE (katello_repositories.id in ...
Updated by Adam Price over 8 years ago
I hit the errata index endpoint 1000 times and averaged the response time to just a little over 4 seconds.
$ curl -k -u admin:changeme 'http://localhost:3000/katello/api/v2/errata?organization_id=3&search=asdfasdf'
# ...
# ...
$ awk '{s+=$1}END{print "avg:",s/NR,"seconds"}' errata.index.txt
avg: 4.02048 seconds
Updated by The Foreman Bot over 8 years ago
- Status changed from New to Ready For Testing
- Pull request https://github.com/Katello/katello/pull/5972 added
Updated by Eric Helms over 8 years ago
- Translation missing: en.field_release set to 86
Updated by Anonymous over 8 years ago
- Status changed from Ready For Testing to Closed
- % Done changed from 0 to 100
Applied in changeset katello|5dd2cae9777b6796f5f933553856a9765644c8f2.
Actions