Primarily aimed at reducing the size of the old 'man' (now: files) table, using smaller integers to refer to man contents and text fields, and storing a shorthash as an integer for quick lookups. This better normalization also removes the need to keep a separate 'man_index' cache for the search function. The old schema wasn't necessarily bad, but I was in the mood for some optimizations. And a little cleanup. Prolly introduces a bunch of new bugs, I haven't tested this too well.
11 lines
494 B
PL/PgSQL
11 lines
494 B
PL/PgSQL
-- Create a new table before replacing in order to avoid a long-held lock on
|
|
-- the table being replaced. The site should remain responsive while these
|
|
-- queries are run.
|
|
BEGIN;
|
|
CREATE TABLE stats_cache_new AS
|
|
SELECT (SELECT count(*) FROM contents) AS hashes,
|
|
(SELECT count(distinct name) FROM mans) AS mans, *
|
|
FROM (SELECT count(*), count(distinct pkgver) FROM files) x(files, packages);
|
|
DROP TABLE stats_cache;
|
|
ALTER TABLE stats_cache_new RENAME TO stats_cache;
|
|
COMMIT;
|