-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: remove dagcargo materialized views (#922)
Sister PR to web3-storage/web3.storage#735 The dagcargo materialized views are taking too long to refresh and are timing out. The entries table is just too big now. We could maybe increase the fetch size to temporarily fix but instead we decided to just remove the materialized views and make the API tolerant of failure.
- Loading branch information
Alan Shaw
authored
Dec 9, 2021
1 parent
039969c
commit 3fe698f
Showing
12 changed files
with
112 additions
and
567 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
CREATE SCHEMA IF NOT EXISTS cargo; | ||
|
||
-- This is a copy of the dagcargo schema for testing purposes. | ||
-- https://github.com/nftstorage/dagcargo/blob/master/maint/pg_schema.sql | ||
|
||
CREATE TABLE IF NOT EXISTS cargo.aggregate_entries ( | ||
aggregate_cid TEXT NOT NULL, | ||
cid_v1 TEXT NOT NULL, | ||
datamodel_selector TEXT NOT NULL | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS cargo.aggregates ( | ||
aggregate_cid TEXT NOT NULL UNIQUE, | ||
piece_cid TEXT UNIQUE NOT NULL, | ||
sha256hex TEXT NOT NULL, | ||
export_size BIGINT NOT NULL, | ||
metadata JSONB, | ||
entry_created TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW() | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS cargo.deals ( | ||
deal_id BIGINT UNIQUE NOT NULL, | ||
aggregate_cid TEXT NOT NULL, | ||
client TEXT NOT NULL, | ||
provider TEXT NOT NULL, | ||
status TEXT NOT NULL, | ||
status_meta TEXT, | ||
start_epoch INTEGER NOT NULL, | ||
start_time TIMESTAMP WITH TIME ZONE NOT NULL, | ||
end_epoch INTEGER NOT NULL, | ||
end_time TIMESTAMP WITH TIME ZONE NOT NULL, | ||
sector_start_epoch INTEGER, | ||
sector_start_time TIMESTAMP WITH TIME ZONE, | ||
entry_created TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), | ||
entry_last_updated TIMESTAMP WITH TIME ZONE NOT NULL | ||
); | ||
|
||
-- Test data | ||
|
||
INSERT INTO cargo.aggregate_entries ("aggregate_cid", "cid_v1", "datamodel_selector") VALUES | ||
('bafybeiek5gau46j4dxoyty27qtirb3iuoq7aax4l3xt25mfk2igyt35bme', 'bafybeiaj5yqocsg5cxsuhtvclnh4ulmrgsmnfbhbrfxrc3u2kkh35mts4e', 'Links/19/Hash/Links/46/Hash/Links/0/Hash'); | ||
|
||
INSERT INTO cargo.aggregates ("aggregate_cid", "piece_cid", "sha256hex", "export_size", "metadata", "entry_created") VALUES | ||
('bafybeiek5gau46j4dxoyty27qtirb3iuoq7aax4l3xt25mfk2igyt35bme', 'baga6ea4seaqfanmqerzaiq7udm5wxx3hcmgapukudbadjarzkadudexamn5gwny', '9ad34a5221cc171dcc61c0862680634ca065c32972ab59f92626b7f2f18ca3fc', 25515304172, '{"Version": 1, "RecordType": "DagAggregate UnixFS"}', '2021-09-09 14:41:14.099613+00'); | ||
|
||
INSERT INTO cargo.deals ("deal_id", "aggregate_cid", "client", "provider", "status", "start_epoch", "end_epoch", "entry_created", "entry_last_updated", "status_meta", "start_time", "sector_start_epoch", "sector_start_time", "end_time") VALUES | ||
(2424132, 'bafybeiek5gau46j4dxoyty27qtirb3iuoq7aax4l3xt25mfk2igyt35bme', 'f144zep4gitj73rrujd3jw6iprljicx6vl4wbeavi', 'f0678914', 'active', 1102102, 2570902, '2021-09-09 16:30:52.252233+00', '2021-09-10 00:45:50.408956+00', 'containing sector active as of 2021-09-10 00:36:30 at epoch 1097593', '2021-09-11 14:11:00+00', 1097593, '2021-09-10 00:36:30+00', '2023-02-03 14:11:00+00'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.