Project

General

Profile

Actions

Bug #14268

closed

two queries are performed when searching for erratum that does not exist

Added by Chris Duryee about 8 years ago. Updated almost 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Performance
Target version:
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

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  ...
Actions #1

Updated by Adam Price about 8 years ago

  • Assignee set to Adam Price
Actions #2

Updated by Adam Price about 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
Actions #3

Updated by The Foreman Bot about 8 years ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/Katello/katello/pull/5972 added
Actions #4

Updated by Eric Helms about 8 years ago

  • translation missing: en.field_release set to 86
Actions #5

Updated by Adam Price almost 8 years ago

  • Bugzilla link set to 1330306
Actions #6

Updated by Anonymous almost 8 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100
Actions

Also available in: Atom PDF