SQL datatypes and internal datatypes
SQL type | Internal type |
smallint | int8 |
int | int32 |
bigint | int64 |
SQL type | Internal type |
smallint | int8 |
int | int32 |
bigint | int64 |
SELECT pg_relation_size(<object_id>, 'main')/8192);The pg_relation_size gives the disk space occupied by the object. Since each page is of 8kB, the pg_relation_size size is divided by 8192 to give the page count.
highlight OverLength ctermbg=red ctermfg=white guibg=#592929
match OverLength /\%81v.\+
=# SELECT
relname as "Table",
pg_size_pretty(pg_total_relation_size(relid)) as "Total Size",
pg_size_pretty(pg_relation_size(relid)) as "Relation 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 | Total Size | Relation Size | External Size
------------------+------------+---------------+---------------
load_test | 1883 MB | 1776 MB | 107 MB
pgbench_accounts | 1121 MB | 961 MB | 161 MB
pgbench_history | 8656 kB | 8656 kB | 0 bytes
pgbench_tellers | 80 kB | 40 kB | 40 kB
pgbench_branches | 24 kB | 8192 bytes | 16 kB
(5 rows)
=# SELECT
indexrelname as "Index",
pg_size_pretty(pg_total_relation_size(indexrelid)) as "Size",
pg_size_pretty(pg_total_relation_size(indexrelid) - pg_relation_size(indexrelid)) as "External Size"
FROM pg_catalog.pg_statio_user_indexes ORDER BY pg_total_relation_size(indexrelid) DESC;
Index | Size | External Size
-----------------------+--------+---------------
pgbench_accounts_pkey | 161 MB | 0 bytes
load_testidx | 107 MB | 0 bytes
pgbench_tellers_pkey | 40 kB | 0 bytes
pgbench_branches_pkey | 16 kB | 0 bytes
(4 rows)
#include "libpq-fe.h"However, it throws the following error:
error: libpq-fe.h: No such file or directoryThis can be solved by including the following in Makefile of that contib
PG_CPPFLAGS = -I$(libpq_srcdir)This includes the option -I../../src/interfaces/libpq during make and hence the header file becomes accessible.
set breakpoint pending on
set detach-on-fork off
Open the document in vim, press v and move to select text and then press one of the following:
U - converts to upper case u - converts to lower case ~ - toggles the case of selected
ggVGureplace u with U for uppercase and ~ to toggle.
vim ~/.psqlrcand add the following to the file
\timingWhen you connect to database and run a query, the time is also displayed:
postgres=# SELECT current_timestamp;
now
----------------------------------
2014-03-11 10:34:40.378455+05:30
(1 row)
Time: 43.821 ms
:let @a=1 | %s/<old_word>/\='<new_word>'.(@a+setreg('a',@a+1))/g