explain query_user role
This commit is contained in:
parent
74af277ea0
commit
bba046a0a0
10
README.md
10
README.md
|
@ -4,11 +4,17 @@ Data is retrieved via Solana RPC and Geysers gRPC API.
|
|||
|
||||
## Database Configuration
|
||||
### Database Roles
|
||||
* `bankingstage_dashboard` - read-only access to the database for the dashboard web application
|
||||
* `bankingstage_sidecar` - write access to the database for the sidecar importer
|
||||
* `bankingstage_dashboard` - read-only access to the database for the dashboard web application
|
||||
* `query_user` - group for read-only access to the database intended for human user interaction with database
|
||||
|
||||
```sql
|
||||
CREATE USER some_user_in_group_query_user PASSWORD 'test';
|
||||
GRANT query_user TO some_user_in_group_query_user;
|
||||
```
|
||||
|
||||
### Configure sidecar PostgreSQL connection
|
||||
export PG_CONFIG="host=localhost dbname=bankingstage user=bankingstage_dashboard password=test sslmode=disable"
|
||||
export PG_CONFIG="host=localhost dbname=the_banking_stage_db user=some_user_in_group_query_user password=test sslmode=disable"
|
||||
|
||||
### Database Schema
|
||||
The database schema is defined in the [migration.sql](migration.sql) file.
|
||||
|
|
|
@ -1,26 +1,27 @@
|
|||
-- setup new postgresql database; tested with PostgreSQL 15
|
||||
|
||||
-- CREATE DATABASE bankingstage3a
|
||||
-- CREATE DATABASE the_banking_stage_db
|
||||
-- run migration.sql
|
||||
|
||||
-- setup sidecar user
|
||||
GRANT CONNECT ON DATABASE bankingstage3a TO bankingstage_sidecar;
|
||||
GRANT CONNECT ON DATABASE the_banking_stage_db TO bankingstage_sidecar;
|
||||
ALTER USER bankingstage_sidecar CONNECTION LIMIT 10;
|
||||
GRANT USAGE ON SCHEMA banking_stage_results_2 TO bankingstage_sidecar;
|
||||
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA banking_stage_results_2 TO bankingstage_sidecar;
|
||||
ALTER DEFAULT PRIVILEGES IN SCHEMA banking_stage_results_2 GRANT ALL PRIVILEGES ON TABLES TO bankingstage_sidecar;
|
||||
GRANT USAGE ON ALL SEQUENCES IN SCHEMA banking_stage_results_2 TO bankingstage_sidecar;
|
||||
ALTER DEFAULT PRIVILEGES IN SCHEMA banking_stage_results_2 GRANT USAGE ON SEQUENCES TO bankingstage_sidecar;
|
||||
|
||||
|
||||
-- setup query_user
|
||||
GRANT CONNECT ON DATABASE bankingstage3a TO query_user;
|
||||
GRANT CONNECT ON DATABASE the_banking_stage_db TO query_user;
|
||||
ALTER USER query_user CONNECTION LIMIT 5;
|
||||
GRANT USAGE ON SCHEMA banking_stage_results_2 TO query_user;
|
||||
GRANT SELECT ON ALL TABLES in SCHEMA banking_stage_results_2 TO query_user;
|
||||
|
||||
|
||||
-- setup bankingstage_dashboard
|
||||
GRANT CONNECT ON DATABASE bankingstage3a TO bankingstage_dashboard;
|
||||
GRANT CONNECT ON DATABASE the_banking_stage_db TO bankingstage_dashboard;
|
||||
ALTER USER bankingstage_sidecar CONNECTION LIMIT 10;
|
||||
GRANT USAGE ON SCHEMA banking_stage_results_2 TO bankingstage_dashboard;
|
||||
GRANT SELECT ON ALL TABLES in SCHEMA banking_stage_results_2 TO bankingstage_dashboard;
|
||||
|
|
|
@ -7,6 +7,8 @@ CREATE TABLE banking_stage_results_2.transactions(
|
|||
signature varchar(88) NOT NULL,
|
||||
UNIQUE(signature)
|
||||
);
|
||||
-- page layout: rows are small and must store in main
|
||||
ALTER TABLE banking_stage_results_2.transactions SET (toast_tuple_threshold=2000);
|
||||
|
||||
CREATE TABLE banking_stage_results_2.transaction_infos (
|
||||
transaction_id BIGINT PRIMARY KEY,
|
||||
|
@ -17,11 +19,13 @@ CREATE TABLE banking_stage_results_2.transaction_infos (
|
|||
prioritization_fees BIGINT NOT NULL,
|
||||
supp_infos text
|
||||
);
|
||||
ALTER TABLE banking_stage_results_2.transaction_infos SET (toast_tuple_threshold=2000);
|
||||
|
||||
CREATE TABLE banking_stage_results_2.errors (
|
||||
error_code int primary key,
|
||||
error_text text
|
||||
);
|
||||
ALTER TABLE banking_stage_results_2.errors SET (toast_tuple_threshold=2000);
|
||||
|
||||
CREATE TABLE banking_stage_results_2.transaction_slot (
|
||||
transaction_id BIGINT,
|
||||
|
@ -31,6 +35,7 @@ CREATE TABLE banking_stage_results_2.transaction_slot (
|
|||
utc_timestamp TIMESTAMP NOT NULL,
|
||||
PRIMARY KEY (transaction_id, slot, error_code)
|
||||
);
|
||||
ALTER TABLE banking_stage_results_2.transaction_slot SET (toast_tuple_threshold=2000);
|
||||
|
||||
|
||||
CREATE INDEX idx_transaction_slot_timestamp ON banking_stage_results_2.transaction_slot(utc_timestamp);
|
||||
|
@ -46,12 +51,14 @@ CREATE TABLE banking_stage_results_2.blocks (
|
|||
total_cu_requested BIGINT NOT NULL,
|
||||
supp_infos text
|
||||
);
|
||||
ALTER TABLE banking_stage_results_2.blocks SET (toast_tuple_threshold=2000);
|
||||
|
||||
CREATE TABLE banking_stage_results_2.accounts(
|
||||
acc_id bigserial PRIMARY KEY,
|
||||
account_key varchar(44) NOT NULL,
|
||||
UNIQUE (account_key)
|
||||
);
|
||||
ALTER TABLE banking_stage_results_2.accounts SET (toast_tuple_threshold=2000);
|
||||
|
||||
CREATE TABLE banking_stage_results_2.accounts_map_transaction(
|
||||
transaction_id BIGINT NOT NULL,
|
||||
|
@ -61,6 +68,7 @@ CREATE TABLE banking_stage_results_2.accounts_map_transaction(
|
|||
is_atl BOOL NOT NULL,
|
||||
PRIMARY KEY (transaction_id, acc_id)
|
||||
);
|
||||
ALTER TABLE banking_stage_results_2.accounts_map_transaction SET (toast_tuple_threshold=2000);
|
||||
|
||||
CREATE INDEX idx_blocks_block_hash ON banking_stage_results_2.blocks(block_hash);
|
||||
|
||||
|
@ -74,6 +82,7 @@ CREATE TABLE banking_stage_results_2.accounts_map_blocks (
|
|||
supp_infos text,
|
||||
PRIMARY KEY (acc_id, slot, is_write_locked)
|
||||
);
|
||||
ALTER TABLE banking_stage_results_2.accounts_map_blocks SET (toast_tuple_threshold=2000);
|
||||
CREATE INDEX idx_accounts_map_blocks_slot ON banking_stage_results_2.accounts_map_blocks(slot);
|
||||
|
||||
insert into banking_stage_results_2.errors (error_text, error_code) VALUES
|
||||
|
@ -119,6 +128,7 @@ CREATE TABLE banking_stage_results_2.accounts_map_transaction_latest(
|
|||
-- sorted: oldest to latest, max 1000
|
||||
tx_ids BIGINT[]
|
||||
);
|
||||
ALTER TABLE banking_stage_results_2.accounts_map_transaction_latest SET (toast_tuple_threshold=2000)
|
||||
|
||||
CREATE OR REPLACE FUNCTION array_dedup_append(base bigint[], append bigint[], n_limit int)
|
||||
RETURNS bigint[]
|
||||
|
|
Loading…
Reference in New Issue