openvibers/openvibe.work Commits
Work company pages read their listings through an index (app time 0.24 s) (#166)
Changes
nnew file mode 100644@@@ -0,0 +1,7 @@++-- phase: expand++-- A company page filters by the slug computed from the board's spelling (server/jobs/companies.js SLUG_SQL). Without an++-- index every query folds all ~15k listings: four such scans made /companies/:slug take ~0.24 s. The expression is++-- immutable, so PostgreSQL can store its value; old code keeps working (it simply does not use the index).++CREATE INDEX IF NOT EXISTS work_listings_company_slug ON work_listings (++ (rtrim(left(trim(both '-' from regexp_replace(translate(lower(company), 'äàáâãåāçćčďđëèéêēğïìíîīłñńňöòóôõøōřŕßśšşťţüùúûůūýÿźżžæœ', 'aaaaaaacccddeeeeegiiiiilnnnooooooorrssssttuuuuuuyyzzzao'), '[^a-z0-9]+', '-', 'g')), 80), '-'))++) WHERE expired = false;@@@ -36,6 +36,11 @@ const companies = require('../server/jobs/companies');for (const r of rows) assert.strictEqual(r.slug, companies.slugOf(r.company), r.company);});++ await check('the company slug is indexed (0008): a page does not fold every listing', async () => {++ const [row] = await s.db.many("SELECT to_regclass('work_listings_company_slug') AS idx");++ assert.strictEqual(String(row.idx), 'work_listings_company_slug');++ });++await check('the index: every company by openings, one entry per slug, the most common spelling; found by name', async () => {const all = await companies.list(s);const acme = all.find((c) => c.slug === 'acme-widgets');
new file mode 100644
new file mode 100644
@@ -0,0 +1,7 @@
@@ -0,0 +1,7 @@
+-- phase: expand
+-- A company page filters by the slug computed from the board's spelling (server/jobs/companies.js SLUG_SQL). Without an
+-- index every query folds all ~15k listings: four such scans made /companies/:slug take ~0.24 s. The expression is
+-- immutable, so PostgreSQL can store its value; old code keeps working (it simply does not use the index).
+CREATE INDEX IF NOT EXISTS work_listings_company_slug ON work_listings (
+ (rtrim(left(trim(both '-' from regexp_replace(translate(lower(company), 'äàáâãåāçćčďđëèéêēğïìíîīłñńňöòóôõøōřŕßśšşťţüùúûůūýÿźżžæœ', 'aaaaaaacccddeeeeegiiiiilnnnooooooorrssssttuuuuuuyyzzzao'), '[^a-z0-9]+', '-', 'g')), 80), '-'))
+) WHERE expired = false;
@@ -36,6 +36,11 @@ const companies = require('../server/jobs/companies');
@@ -36,6 +36,11 @@ const companies = require('../server/jobs/companies');
for (const r of rows) assert.strictEqual(r.slug, companies.slugOf(r.company), r.company);
for (const r of rows) assert.strictEqual(r.slug, companies.slugOf(r.company), r.company);
});
});
+ await check('the company slug is indexed (0008): a page does not fold every listing', async () => {
+ const [row] = await s.db.many("SELECT to_regclass('work_listings_company_slug') AS idx");
+ assert.strictEqual(String(row.idx), 'work_listings_company_slug');
+ });
+
await check('the index: every company by openings, one entry per slug, the most common spelling; found by name', async () => {
await check('the index: every company by openings, one entry per slug, the most common spelling; found by name', async () => {
const all = await companies.list(s);
const all = await companies.list(s);
const acme = all.find((c) => c.slug === 'acme-widgets');
const acme = all.find((c) => c.slug === 'acme-widgets');