-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Use TEXT instead of VARCHAR See "Tip" here https://www.postgresql.org/docs/current/datatype-character.html * Add casted index for u64 values used to sort results * Cast as numeric so the index is actually used * Update changelog
- Loading branch information
Showing
4 changed files
with
25 additions
and
18 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,14 +1,17 @@ | ||
-- SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
CREATE TABLE IF NOT EXISTS entries ( | ||
author VARCHAR(64) NOT NULL, | ||
entry_bytes TEXT NOT NULL, | ||
entry_hash VARCHAR(68) NOT NULL UNIQUE, | ||
-- Store u64 integer as 20 character string | ||
log_id VARCHAR(20) NOT NULL, | ||
author TEXT NOT NULL, | ||
entry_bytes TEXT NOT NULL, | ||
entry_hash TEXT NOT NULL UNIQUE, | ||
-- Store u64 integer as character string | ||
log_id TEXT NOT NULL, | ||
payload_bytes TEXT, | ||
payload_hash VARCHAR(68) NOT NULL, | ||
-- Store u64 integer as 20 character string | ||
seq_num VARCHAR(20) NOT NULL, | ||
payload_hash TEXT NOT NULL, | ||
-- Store u64 integer as character string | ||
seq_num TEXT NOT NULL, | ||
PRIMARY KEY (author, log_id, seq_num) | ||
); | ||
|
||
-- Create an index for sorting by sequence number | ||
CREATE INDEX idx_entries_by_seq_num ON entries (CAST(seq_num AS NUMERIC)); |
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 |
---|---|---|
@@ -1,14 +1,17 @@ | ||
-- SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
CREATE TABLE IF NOT EXISTS logs ( | ||
author VARCHAR(64) NOT NULL, | ||
document VARCHAR(68) NOT NULL, | ||
-- Store u64 integer as 20 character string | ||
log_id VARCHAR(20) NOT NULL, | ||
schema VARCHAR(68) NOT NULL, | ||
author TEXT NOT NULL, | ||
document TEXT NOT NULL, | ||
-- Store u64 integer as text | ||
log_id TEXT NOT NULL, | ||
schema TEXT NOT NULL, | ||
PRIMARY KEY (author, document, log_id), | ||
UNIQUE(author, log_id) | ||
); | ||
|
||
-- Create an index for querying by schema | ||
CREATE INDEX idx_logs_schema ON logs (author, log_id, schema); | ||
|
||
-- Create an index for sorting by log id | ||
CREATE INDEX idx_logs_by_id ON logs (CAST(log_id AS NUMERIC)); |
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