Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(fill-short-hash): migrate back-fill short_hash for old existing … #123

Merged
merged 1 commit into from
May 22, 2024

Conversation

tx0c
Copy link
Contributor

@tx0c tx0c commented Apr 29, 2024

…articles

the migrate for thematters/matters-web#4196 ; not in matters-server is for using the UPDATE ... FROM UNNEST(...) batch updating syntax much more efficient, and which is not in knex-2.4 by matters-server yet;

$ time PGIDLE_TIMEOUT=5 PGPASSWORD='xxx' \
    PG_CONNECTION_STRING='postgresql://[email protected]/database' \
    BATCH_SIZE=3200 \
    node --trace-warnings ./dist/bin/fill-short-hash.js
debug: query --:

      select b.oid, b.typarray
      from pg_catalog.pg_type a
      left join pg_catalog.pg_type b on b.oid = a.typelem
      where a.typcategory = 'A'
      group by b.oid, b.typarray
      order by b.oid

 { connection: 2, params: [], types: [] }
debug: query --:
SELECT (short_hash IS NOT NULL) short_hash, COUNT(*) ::int FROM public.article GROUP BY 1 ;
 { connection: 2, params: [], types: [] }
2024-04-29T07:07:19.530Z get stats: Result(1) [ { shortHash: true, count: 584509 } ]
debug: query --:
ALTER TABLE article ALTER COLUMN short_hash SET NOT NULL ;
 { connection: 2, params: [], types: [] }
[...]

@gary02 gary02 self-requested a review May 10, 2024 05:43
SET short_hash=last_batch_with_hash.short_hash
FROM last_batch_with_hash
WHERE article.id=last_batch_with_hash.id
RETURNING article.* ; `
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can only return "article.id" ?

@tx0c tx0c force-pushed the feat/fill-short-hash branch from 5b95972 to 65eb73b Compare May 22, 2024 01:53
@tx0c tx0c merged commit 65eb73b into main May 22, 2024
2 checks passed
…articles

the migrate for thematters/matters-web#4196 ; not in matters-server is for
using the `UPDATE ... FROM UNNEST(...)` batch updating syntax much more efficient,
and which is not in knex-2.4 by matters-server yet;

```console
$ time PGIDLE_TIMEOUT=5 PGPASSWORD='xxx' \
    PG_CONNECTION_STRING='postgresql://[email protected]/database' \
    BATCH_SIZE=3200 \
    node --trace-warnings ./dist/bin/fill-short-hash.js
debug: query --:

      select b.oid, b.typarray
      from pg_catalog.pg_type a
      left join pg_catalog.pg_type b on b.oid = a.typelem
      where a.typcategory = 'A'
      group by b.oid, b.typarray
      order by b.oid

 { connection: 2, params: [], types: [] }
debug: query --:
SELECT (short_hash IS NOT NULL) short_hash, COUNT(*) ::int FROM public.article GROUP BY 1 ;
 { connection: 2, params: [], types: [] }
2024-04-29T07:07:19.530Z get stats: Result(1) [ { shortHash: true, count: 584509 } ]
debug: query --:
ALTER TABLE article ALTER COLUMN short_hash SET NOT NULL ;
 { connection: 2, params: [], types: [] }
[...]
```
@gitwoz gitwoz deleted the feat/fill-short-hash branch August 29, 2024 04:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants