Commit graph

39 commits

Author SHA1 Message Date
Yorhel
1ee5c9c2df SQL: Add packages.c_hasman cache to speed up package listings
Going from average ~100ms to ~10ms or so. The previous query had a
tendency to be much slower sometimes, let's see if this cache also takes
care of those outliers.

Migration script:

  ALTER TABLE packages ADD COLUMN c_hasman boolean NOT NULL DEFAULT FALSE;

  DROP INDEX packages_system_name_key;
  CREATE UNIQUE INDEX packages_system_name_key ON packages (system, name) INCLUDE (id, c_hasman, dead);

  UPDATE packages SET c_hasman = NOT c_hasman
   WHERE c_hasman <> EXISTS(SELECT 1 FROM package_versions pv WHERE pv.package = packages.id AND EXISTS(SELECT 1 FROM files f WHERE f.pkgver = pv.id));
2024-04-29 21:15:40 +02:00
Yorhel
83ab6c3671 Get rid of package categories
Whether or not the package name itself or the (category,name) tuple
uniquely identified a package within a system has been a source of
confusion for a long time. Back in
03d278e4ff I ended up playing playing it
"safe" by going for (category,name), but in practice this doesn't make a
whole lot of sense. While it's *possible* for the same package name to
refer to completely different packages in different "categories", in
reality distributions can't sanely support this anyway.

For distributions where the category referred to a repository, the only
cases where the same package name was used in different repos was when
the package has moved from one repo to another. Those should certainly
not be treated as different packages.

For distributions where the category really referred to a category,
there's the Debian approach where the category is purely a tag and
doesn't help identify the package in any way, and then there's FreeBSD
where the category technically ought to be part of the name.  There were
a few cases where FreeBSD used categories to separate out different
versions of the same package (e.g. ipv6 vs non-ipv6), but none were
relevant for man pages so I ended up merging those as well.

Getting rid of the categories simplifies and shortens URLs, unclutters
the UI a little bit and merges the packages in listings that should've
been merged all along.

Migration script:

  -- Merge packages that are in multiple categories.
  -- All versions are moved to the package with the lowest ID.
  -- If the same version already exists in a lower ID, the higher-ID version is deleted.
  BEGIN;
  WITH migrate(old, new, second) AS (
    SELECT q.id, MIN(p.id), MAX(p.id)
      FROM packages p
      JOIN packages q ON q.id > p.id AND p.system = q.system AND p.name = q.name
     GROUP BY q.id
  ), ded(n) AS (
    UPDATE packages SET dead = false
      FROM migrate m
      JOIN packages q ON q.id = m.old
     WHERE packages.id = m.new AND packages.dead AND NOT q.dead
    RETURNING 1
  ), mov(n) AS (
    UPDATE package_versions SET package = m.new
      FROM migrate m
     WHERE package_versions.package = m.old
       AND NOT EXISTS(
          SELECT 1
            FROM package_versions v
           WHERE v.package IN(m.new, m.second)
             AND v.version = package_versions.version)
    RETURNING 1
  ), del(n) AS (
    DELETE FROM packages WHERE id IN(SELECT old FROM migrate)
    RETURNING 1
  ) SELECT (SELECT count(*) FROM migrate) AS migrate,
           (SELECT count(*) FROM ded) AS ded,
           (SELECT count(*) FROM mov) AS mov,
           (SELECT count(*) FROM del) AS del;

  ALTER TABLE packages DROP CONSTRAINT packages_system_name_category_key;
  CREATE UNIQUE INDEX packages_system_name_key ON packages (system, name);
  ALTER TABLE packages DROP COLUMN category;
  COMMIT;
2024-04-28 10:37:04 +02:00
Yorhel
f92639d22c Cleanup SQL files 2024-04-14 11:35:39 +02:00
Yorhel
03d278e4ff Normalize package info tables + change browsing URLs
This splits the 'package' table into 'packages' and 'package_versions',
which should improve performance in some cases and simplify some future
queries.

Previously it wasn't very well defined whether packages were uniquely
identified by (system, name) or by (system, category, name). This is now
normalized to the latter form. This required changes to the package URLs
to include the category.
2016-10-02 20:07:57 +02:00
Yorhel
26aefaebcd Add Ubuntu Xenial 2016-06-26 21:39:31 +02:00
Yorhel
0c6964d0e3 Minor cleanup 2016-06-26 11:33:16 +02:00
Yorhel
f7f79ad80d Don't sync old deb repos + add Ubuntu wily 2016-03-05 08:06:23 +01:00
Yorhel
2da67d585c Various changes/fixes, 3 new distro versions 2015-04-28 08:27:29 +02:00
Yorhel
977f6216bd Added and indexed Ubuntu Trusty
Somewhat late. I still need to index the recent FreeBSD releases, too...
2014-05-26 09:32:27 +02:00
Yorhel
61d822a76b Added and indexed Ubuntu 13.10 2013-10-20 08:24:52 +02:00
Yorhel
000ffd33f6 Added and indexed FreeBSD 9.2 2013-10-19 20:18:00 +02:00
Yorhel
70fb2014b2 Added and indexed FreeBSD 9.1 2013-08-25 18:09:30 +02:00
Yorhel
9ba0d311e2 Added and indexed FreeBSD 8.4 2013-08-22 14:56:40 +02:00
Yorhel
dbc2cac13b Added and indexed Debian Wheezy 2013-05-10 15:14:44 +02:00
Yorhel
7c9dbffd6a Added and indexed Ubuntu raring + disable TUWF debug mode 2013-04-27 07:12:51 +02:00
Yorhel
f240d6117a Added and indexed Ubuntu 12.10 2012-10-18 16:57:30 +02:00
Yorhel
ed393a8fae Fix Freebsd -> FreeBSD erorr in schema.sql 2012-08-15 16:29:01 +02:00
Yorhel
8c94298bf4 Added and indexed FreeBSD 8.x and 9.0 2012-08-14 20:25:38 +02:00
Yorhel
ad0739ed7f Added and indexed FreeBSD 7.x 2012-08-08 18:38:19 +02:00
Yorhel
7e9acec5e6 Added and indexed FreeBSD 6.x + minor fixes in 5.x 2012-08-04 13:48:28 +02:00
Yorhel
aa47337cd1 Added and indexed FreeBSD 5.x 2012-08-01 19:40:43 +02:00
Yorhel
75741305c2 Added and indexed the remaining FreeBSD 4.x releases 2012-07-30 14:58:55 +02:00
Yorhel
5e963de411 Added and indexed FreeBSD 3.5, 3.5.1 and 4.0
Things are slowing down a bit now that the later releases have a
packages/ directory.
2012-07-27 18:10:25 +02:00
Yorhel
40f916c4cf Added and indexed FreeBSD 3.0 - 3.4 2012-07-27 12:54:51 +02:00
Yorhel
61566c93fb Added and indexed FreeBSD 2.2.2, 2.2.5, 2.2.6 and 2.2.7.
Their repositories were all rather similar, so hardly anything special
needed. (2.2.8, on the other hand, is the first with a categorized
packages/ dir)
2012-07-26 14:16:06 +02:00
Yorhel
0c641931e5 Added and indexed FreeBSD 2.0.5, 2.1.5 and 2.1.7 2012-07-26 13:39:30 +02:00
Yorhel
2f288c9eeb Added and indexed FreeBSD 1.0 2012-07-26 11:42:00 +02:00
Yorhel
0738583243 Cache stats in the database (and auto-update them from cron) 2012-07-18 10:21:13 +02:00
Yorhel
10e8d4acae Added search index table + simple XML-based search interface
The XML thing is supposed to be used for auto-completion, of course. The
current search implementation is very, very stupid and simple: Just a
prefix match on the man name, and simple detection of section stuff. I
suppose it'll suffice for now.
2012-07-17 18:49:38 +02:00
Yorhel
b463d8e87e Added Debian Lenny & Squeeze 2012-07-06 18:56:24 +02:00
Yorhel
862f42dce5 Added and indexed Debian woody, sarge and etch 2012-07-05 15:12:01 +02:00
Yorhel
00f5ab0572 Added Debian hamm/slink/potato + about manned.org update 2012-07-04 13:56:54 +02:00
Yorhel
531882296f Added and indexed early Debian versions 2012-07-04 12:34:08 +02:00
Yorhel
1f4328a72c Improved CSS browser compat. + misc layout improvements 2012-07-02 13:22:37 +02:00
Yorhel
e74ae0ae67 Added the remaining Ubuntu releases 2012-06-20 17:59:28 +02:00
Yorhel
b1d1da66e7 Added Ubuntu 6.10, 7.04 and 7.10 2012-06-18 15:18:07 +02:00
Yorhel
7015defba1 Added Ubuntu 6.06 2012-06-16 12:29:21 +02:00
Yorhel
767fbe595d A few minor optimizations + better ordering of systems in manselect() 2012-06-15 15:56:57 +02:00
Yorhel
c47f450934 Initial commit 2012-06-15 14:23:29 +02:00