데이터베이스 크기를 이해하는 데 도움이 필요합니다. 나는 질문이 친절한 데이터베이스 프로를 위해 의 종류라고 생각합니다. 나는 프로가 아니지만 이해하고 싶습니다. 나는 PostgreSQL을 사용한다. 하나 더 자세하게. 내 응용 프로그램은 java로 작성되었으며 평가판 계정의 PWS 클라우드에 배포됩니다. 최대 여유 데이터베이스 크기는 20MB입니다. 그것은 시험 및 개발 에 충분합니다. 그리고 몇 달 후 데이터베이스의 크기가 제한을 초과하여 약 25MB가되었습니다. 하지만 사용자의 관점 (사실 내 관점에서 볼 때)은 내 데이터의 크기가 25MB보다 훨씬 작습니다 ( ). 그래서 나는 공간을 차지하는 것이 무엇인지 찾아야합니다. 여기사용자 테이블의 크기가 PostgreSQL 데이터베이스의 다른 개체 크기보다 훨씬 작은 이유
# \d
List of relations
Schema | Name | Type
--------+--------------------+----------
public | hibernate_sequence | sequence
public | post | table
public | site | table
public | user_account | table
public | user_authority | table
public | userconnection | table
(6 rows)
# \d post
Table "public.post"
Column | Type | Modifiers
----------------+-----------------------------+-----------
id | bigint | not null
author | character varying(255) |
content | text | not null
creation_time | timestamp without time zone | not null
tags | character varying(255) |
title | text | not null
url | character varying(255) | not null
site_id | bigint | not null
published_date | timestamp without time zone | not null
uri | character varying(255) | not null
Indexes:
"post_pkey" PRIMARY KEY, btree (id)
Foreign-key constraints:
"fkadd3gkkmgwsi1dy825qkfd62e" FOREIGN KEY (site_id) REFERENCES site(id)
# \d site
Table "public.site"
Column | Type | Modifiers
--------------+-----------------------------+-----------
id | bigint | not null
last_visited | timestamp without time zone |
title | text |
url | character varying(255) | not null
description | text |
Indexes:
"site_pkey" PRIMARY KEY, btree (id)
Referenced by:
TABLE "post" CONSTRAINT "fkadd3gkkmgwsi1dy825qkfd62e" FOREIGN KEY (site_id) REFERENCES site(id)
# \d user_account
Table "public.user_account"
Column | Type | Modifiers
-------------------+-----------------------------+-----------
id | bigint | not null
email | character varying(255) | not null
first_name | character varying(255) |
last_name | character varying(255) |
last_request_time | timestamp without time zone | not null
password | character varying(255) | not null
registration_time | timestamp without time zone | not null
Indexes:
"user_account_pkey" PRIMARY KEY, btree (id)
"uk_hl02wv5hym99ys465woijmfib" UNIQUE CONSTRAINT, btree (email)
Referenced by:
TABLE "user_authority" CONSTRAINT "fkn48a3n0mb8d8njshjf75kgsv" FOREIGN KEY (user_id) REFERENCES user_account(id)
# \d userconnection
Table "public.userconnection"
Column | Type | Modifiers
----------------+------------------------+-----------
userid | character varying(255) | not null
providerid | character varying(255) | not null
provideruserid | character varying(255) | not null
rank | integer | not null
displayname | character varying(255) |
profileurl | character varying(512) |
imageurl | character varying(512) |
accesstoken | character varying(512) | not null
secret | character varying(512) |
refreshtoken | character varying(512) |
expiretime | bigint |
Indexes:
"userconnection_pkey" PRIMARY KEY, btree (userid, providerid, provideruserid)
"userconnectionrank" UNIQUE, btree (userid, providerid, rank)
# \d user_authority
Table "public.user_authority"
Column | Type | Modifiers
-----------+------------------------+-----------
authority | character varying(255) | not null
user_id | bigint | not null
Indexes:
"user_authority_pkey" PRIMARY KEY, btree (user_id, authority)
Foreign-key constraints:
"fkn48a3n0mb8d8njshjf75kgsv" FOREIGN KEY (user_id) REFERENCES user_account(id)
Here's the databases's size:
select pg_database_size('rodiahug');
pg_database_size
25714860
내 테이블의 크기를 알아 내기 위해 사용하는 쿼리는 다음과 같습니다 : 우리는 모든 크기를 추가 참조로
SELECT
relname as "Table",
pg_size_pretty(pg_total_relation_size(relid)) As "Size",
pg_size_pretty(pg_total_relation_size(relid) - pg_relation_size(relid)) as "External Size"
FROM pg_catalog.pg_statio_user_tables ORDER BY pg_total_relation_size(relid) DESC;
Table Size External Size
site 64 kB 56 kB
user_account 48 kB 40 kB
post 48 kB 24 kB
userconnection 48 kB 40 kB
user_authority 24 kB 16 kB
보다 훨씬 덜되어
그래서, 여기에 데이터베이스 구조입니다 24MB.
객체의 크기에 대한 쿼리에 대한 순진 구글 검색 쿼리 제공 :
SELECT
relname AS objectname,
relkind AS objecttype,
reltuples AS "#entries", pg_size_pretty(relpages::bigint*8*1024) AS size
FROM pg_class
WHERE relpages >= 1 AND reltuples > 0
ORDER BY relpages DESC;
objectname objecttype #entries size
pg_largeobject r 129767.0 6152 kB
pg_largeobject_metadata r 131790.0 5704 kB
pg_shdepend_depender_index i 71390.0 4368 kB
pg_shdepend r 71390.0 4296 kB
pg_largeobject_metadata_oid_index i 131790.0 2912 kB
pg_largeobject_loid_pn_index i 129767.0 2872 kB
pg_shdepend_reference_index i 71390.0 2576 kB
pg_database r 5048.0 1496 kB
pg_proc r 3473.0 712 kB
pg_depend r 11312.0 672 kB
pg_authid r 2921.0 448 kB
pg_attribute r 2573.0 376 kB
pg_depend_depender_index i 11312.0 368 kB
pg_depend_reference_index i 11312.0 368 kB
pg_description r 3876.0 272 kB
pg_proc_proname_args_nsp_index i 3473.0 264 kB
pg_database_datname_index i 4214.0 176 kB
pg_authid_rolname_index i 2901.0 168 kB
pg_statistic r 422.0 144 kB
pg_operator r 907.0 136 kB
pg_attribute_relid_attnam_index i 2573.0 136 kB
pg_database_oid_index i 4214.0 136 kB
pg_description_o_c_o_index i 3876.0 136 kB
pg_rewrite r 115.0 96 kB
pg_proc_oid_index i 3473.0 96 kB
pg_attribute_relid_attnum_index i 2573.0 96 kB
pg_authid_oid_index i 2901.0 88 kB
pg_type r 416.0 80 kB
pg_collation r 303.0 80 kB
pg_amop r 1025.0 72 kB
pg_class r 337.0 72 kB
pg_amproc r 904.0 56 kB
pg_class_relname_nsp_index i 337.0 56 kB
pg_amproc_fam_proc_index i 904.0 48 kB
pg_operator_oprname_l_r_n_index i 907.0 48 kB
pg_amop_opr_fam_index i 1025.0 48 kB
pg_type_typname_nsp_index i 416.0 48 kB
pg_amop_fam_strat_index i 1025.0 48 kB
pg_class_tblspc_relfilenode_index i 337.0 40 kB
pg_amop_oid_index i 1025.0 40 kB
pg_operator_oid_index i 907.0 40 kB
pg_amproc_oid_index i 904.0 40 kB
pg_class_oid_index i 337.0 40 kB
pg_ts_config_map_index i 304.0 32 kB
pg_statistic_relid_att_inh_index i 422.0 32 kB
pg_collation_name_enc_nsp_index i 303.0 32 kB
pg_type_oid_index i 416.0 32 kB
pg_opclass_am_name_nsp_index i 219.0 32 kB
pg_opclass r 219.0 32 kB
pg_conversion r 132.0 24 kB
post r 67.0 24 kB
pg_toast_2619 t 15.0 24 kB
pg_index r 131.0 24 kB
pg_opfamily r 172.0 24 kB
pg_rewrite_oid_index i 115.0 16 kB
pg_rewrite_rel_rulename_index i 115.0 16 kB
pg_trigger_tgconstraint_index i 8.0 16 kB
pg_trigger_tgrelid_tgname_index i 8.0 16 kB
pg_namespace_nspname_index i 6.0 16 kB
pg_namespace_oid_index i 6.0 16 kB
pg_ts_config_cfgname_index i 16.0 16 kB
pg_ts_config_oid_index i 16.0 16 kB
pg_ts_dict_dictname_index i 19.0 16 kB
pg_ts_dict_oid_index i 19.0 16 kB
pg_ts_parser_prsname_index i 1.0 16 kB
pg_ts_parser_oid_index i 1.0 16 kB
pg_ts_template_tmplname_index i 8.0 16 kB
pg_ts_template_oid_index i 8.0 16 kB
pg_foreign_data_wrapper_oid_index i 1.0 16 kB
pg_foreign_data_wrapper_name_index i 1.0 16 kB
pg_extension_oid_index i 24.0 16 kB
pg_range_rngtypid_index i 6.0 16 kB
site_pkey i 3.0 16 kB
userconnectionrank i 4.0 16 kB
userconnection_pkey i 4.0 16 kB
pg_index_indexrelid_index i 131.0 16 kB
pg_am_oid_index i 6.0 16 kB
pg_aggregate_fnoid_index i 140.0 16 kB
pg_index_indrelid_index i 131.0 16 kB
pg_cast_oid_index i 224.0 16 kB
pg_cast_source_target_index i 224.0 16 kB
pg_conversion_default_index i 132.0 16 kB
pg_conversion_name_nsp_index i 132.0 16 kB
pg_conversion_oid_index i 132.0 16 kB
pg_constraint_contypid_index i 13.0 16 kB
pg_constraint_conrelid_index i 13.0 16 kB
pg_collation_oid_index i 303.0 16 kB
pg_pltemplate_name_index i 8.0 16 kB
pg_constraint_conname_nsp_index i 13.0 16 kB
pg_shdescription_o_c_index i 1.0 16 kB
pg_tablespace_oid_index i 2.0 16 kB
pg_tablespace_spcname_index i 2.0 16 kB
pg_toast_2619_index i 15.0 16 kB
user_authority_pkey i 5.0 16 kB
pg_opfamily_am_name_nsp_index i 172.0 16 kB
pg_opfamily_oid_index i 172.0 16 kB
pg_opclass_oid_index i 219.0 16 kB
pg_language_name_index i 5.0 16 kB
pg_language_oid_index i 5.0 16 kB
user_account_pkey i 3.0 16 kB
uk_hl02wv5hym99ys465woijmfib i 3.0 16 kB
pg_cast r 224.0 16 kB
pg_ts_config_map r 304.0 16 kB
pg_extension_name_index i 24.0 16 kB
post_pkey i 67.0 16 kB
pg_constraint_oid_index i 13.0 16 kB
pg_aggregate r 140.0 16 kB
pg_trigger_oid_index i 8.0 16 kB
pg_am_name_index i 6.0 16 kB
pg_ts_config r 16.0 8192 bytes
pg_am r 6.0 8192 bytes
pg_ts_dict r 19.0 8192 bytes
pg_ts_parser r 1.0 8192 bytes
pg_ts_template r 8.0 8192 bytes
pg_extension r 24.0 8192 bytes
pg_foreign_data_wrapper r 1.0 8192 bytes
user_account r 3.0 8192 bytes
pg_range r 6.0 8192 bytes
pg_constraint r 13.0 8192 bytes
pg_tablespace r 2.0 8192 bytes
user_authority r 5.0 8192 bytes
pg_shdescription r 1.0 8192 bytes
site r 3.0 8192 bytes
pg_trigger r 8.0 8192 bytes
userconnection r 4.0 8192 bytes
pg_language r 5.0 8192 bytes
pg_namespace r 6.0 8192 bytes
pg_pltemplate r 8.0 8192 bytes
hibernate_sequence S 1.0 8192 bytes
을 그리고 여기 내 사용자 테이블보다 훨씬 더 많은 공간 을 차지 왜 이러한 개체를 이해하고 싶어? 예를 들어 이 :
pg_largeobject r 129767.0 6152 kB
pg_largeobject_metadata r 131790.0 5704 kB
pg_shdepend_depender_index i 71390.0 4368 kB
pg_shdepend r 71390.0 4296 kB
pg_largeobject_metadata_oid_index i 131790.0 2912 kB
pg_largeobject_loid_pn_index i 129767.0 2872 kB
pg_shdepend_reference_index i 71390.0 2576 kB
pg_database r 5048.0 1496 kB
이 정상인가요? 해야합니까/그것에 대해 뭔가 할 수 있습니까?