Last active
January 22, 2023 08:13
-
-
Save magicpotion/e4965b90c83ae55b7103b80e53cae43d to your computer and use it in GitHub Desktop.
Databases API & Stuff ty
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
Databases API & Stuff |
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
GET /_nodes/hot_threads | |
GET /_ingest/pipeline/ | |
GET /index/_ilm/explain | |
GET /_tasks?detailed=true&actions=*reindex | |
GET /_tasks?detailed=true&actions=*merge | |
GET /_tasks?detailed=true&actions | |
GET /_cluster/health | |
GET /_cluster/settings | |
GET /_cat/allocation?v=true # disk space | |
GET /_cat/templates?s=name # templates list | |
GET /_cat/shards?h=index,shard,prirep,state,unassigned.reason| | |
GET /_cat/thread_pool/generic?v&h=id,name,active,rejected,completed | |
POST /_cluster/reroute?retry_failed | |
GET /{index}/_segments | |
POST /{index}/_forcemerge?max_num_segments=1 | |
GET /_template/{index} | |
DELETE /_template/{index} | |
PUT {index}/_settings | |
{ | |
"index.refresh_interval": "-1", # disable on reindex | |
"index.number_of_replicas" : 0, # disable on reindex | |
"index.merge.policy.expunge_deletes_allowed": -1 # remove all deletes during forcemerge | |
} | |
POST _reindex | |
{ | |
"source": { | |
"index": ["apm-7.4.2-error-2021.01", "apm-7.4.2-error-2021.02"], | |
"_source": ["@timestamp", "host.hostname", ...] | |
}, | |
"dest": { | |
"index": "apm-7.4.2-error-2021", | |
"op_type": "create" | |
} | |
} | |
PUT /_snapshot/s3-backup/{{BACKUP_NAME}}?wait_for_completion=true | |
{ | |
"indices": "{{INDEXES_NAME}}", | |
"ignore_unavailable": true, | |
"include_global_state": false | |
} | |
POST {index}/_forcemerge?only_expunge_deletes=true | |
POST {index}/_forcemerge?max_num_segments=1 |
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
## MAC | |
# homebrew installed | |
vim /usr/local/var/postgresql\@11/postgresql.conf | |
tail -f /usr/local/var/log/postgresql@11.log | |
# DEBIAN | |
vim /etc/postgresql/11/main/postgresql.conf |
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
### CONFIG ### | |
SHOW config_file; | Config Directory | |
SHOW log_directory; | Log Directory | |
### DUPLICATE DATABASE ### | |
CREATE DATABASE <new_database> TEMPLATE <old_database>; | |
### DUMP TABLE TO SQL/CSV/JSON ### | |
:$ pg_dump -t <TABLE> <DATABASE> > <FILENAME>.sql | |
COPY persons TO 'Users/krystian/persons_db.csv' CSV; | |
\COPY (SELECT ROW_TO_JSON(t) FROM (SELECT * FROM <TABLE>) t) to '~/<FILENAME>.json'; | |
### RECREATE SEQUENCE ### | |
select max(id) from {TABLE}; | |
create sequence {TABLE}_id_seq START 1 OWNED BY {TABLE}.id; | |
alter table {TABLE} alter COLUMN id set default nextval('{TABLE}_id_seq'); | |
drop sequence {WRONGTABLE}_id_seq; | |
### UPDATE SEQUENCE ### | |
select setval('@@_id_seq', coalesce(( select max(id)+1 from @@),1), false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment