rfc4492 & rfc5289 定义了该 CipherSuite 的具体实现。
the long term authenticity is confirmed via the server cert’s RSA signature but the transient keys are derived via ephemeral EC keys (which then generate the symmetric key)
ECDHE-RSA uses Diffie-Hellman on an elliptic curve group while DHE-RSA uses Diffie-Hellman on a modulo-prime group.
Set-Cookie: qwerty=219ffwef9w0f; Domain=somecompany.co.uk; Path=/; Expires=Wed, 30 Aug 2019 00:00:00 GMT
Retry-After响应的 HTTP 报头指示所述用户代理应该多长时间使一个后续请求之前等待。有两种主要的情况使用这个头文件: When sent with a 503 (Service Unavailable) response, it indicates how long the service is expected to be unavailable. 纠错 当使用重定向响应(如301永久移动)发送时,它表示用户
General options: --threads=N number of threads to use [1] --events=N limit for total number of events [0] --time=N limit for total execution time in seconds [10] --forced-shutdown=STRING number of seconds to wait after the --time limit before forcing shutdown, or 'off' to disable [off] --thread-stack-size=SIZE size of stack per thread [64K] --rate=N average transactions rate. 0 for unlimited rate [0] --report-interval=N periodically report intermediate statistics with a specified interval in seconds. 0 disables intermediate reports [0] --report-checkpoints=[LIST,...] dump full statistics and reset all counters at specified points in time. The argument is a list of comma-separated values representing the amount of time in seconds elapsed from start of test when report checkpoint(s) must be performed. Report checkpoints are off by default. [] --debug[=on|off] print more debugging info [off] --validate[=on|off] perform validation checks where possible [off] --help[=on|off] print help and exit [off] --version[=on|off] print version and exit [off] --config-file=FILENAME File containing command line options --tx-rate=N deprecated alias for --rate [0] --max-requests=N deprecated alias for --events [0] --max-time=N deprecated alias for --time [0] --num-threads=N deprecated alias for --threads [1]
Pseudo-Random Numbers Generator options: --rand-type=STRING random numbers distribution {uniform,gaussian,special,pareto} [special] --rand-spec-iter=N number of iterations used for numbers generation [12] --rand-spec-pct=N percentage of values to be treated as 'special' (for special distribution) [1] --rand-spec-res=N percentage of 'special' values to use (for special distribution) [75] --rand-seed=N seed for random number generator. When 0, the current time is used as a RNG seed. [0] --rand-pareto-h=N parameter h for pareto distribution [0.2]
--percentile=N percentile to calculate in latency statistics (1-100). Use the special value of 0 to disable percentile calculations [95] --histogram[=on|off] print latency histogram in report [off]
General database options:
--db-driver=STRING specifies database driver to use ('help' to get list of available drivers) [mysql] --db-ps-mode=STRING prepared statements usage mode {auto, disable} [auto] --db-debug[=on|off] print database-specific debug information [off]
Compiled-in database drivers: mysql - MySQL driver pgsql - PostgreSQL driver
mysql options: --mysql-host=[LIST,...] MySQL server host [localhost] --mysql-port=[LIST,...] MySQL server port [3306] --mysql-socket=[LIST,...] MySQL socket --mysql-user=STRING MySQL user [sbtest] --mysql-password=STRING MySQL password [] --mysql-db=STRING MySQL database name [sbtest] --mysql-ssl[=on|off] use SSL connections, if available in the client library [off] --mysql-ssl-cipher=STRING use specific cipher for SSL connections [] --mysql-compression[=on|off] use compression, if available in the client library [off] --mysql-debug[=on|off] trace all client library calls [off] --mysql-ignore-errors=[LIST,...] list of errors to ignore, or "all" [1213,1020,1205] --mysql-dry-run[=on|off] Dry run, pretend that all MySQL client API calls are successful without executing them [off]
pgsql options: --pgsql-host=STRING PostgreSQL server host [localhost] --pgsql-port=N PostgreSQL server port [5432] --pgsql-user=STRING PostgreSQL user [sbtest] --pgsql-password=STRING PostgreSQL password [] --pgsql-db=STRING PostgreSQL database name [sbtest]
Compiled-in tests: fileio - File I/O test cpu - CPU performance test memory - Memory functions speed test threads - Threads subsystem performance test mutex - Mutex performance test
General options: -c, --command=COMMAND run only single command (SQL or internal) and exit -d, --dbname=DBNAME database name to connect to (default: "postgres") -f, --file=FILENAME execute commands from file, thenexit -l, --list list available databases, thenexit -v, --set=, --variable=NAME=VALUE set psql variable NAME to VALUE (e.g., -v ON_ERROR_STOP=1) -V, --version output version information, thenexit -X, --no-psqlrc do not read startup file (~/.psqlrc) -1 ("one"), --single-transaction execute as a single transaction (if non-interactive) -?, --help[=options] show this help, thenexit --help=commands list backslash commands, thenexit --help=variables list special variables, thenexit
Input and output options: -a, --echo-all echo all input from script -b, --echo-errors echo failed commands -e, --echo-queries echo commands sent to server -E, --echo-hidden display queries that internal commands generate -L, --log-file=FILENAME send session log to file -n, --no-readline disable enhanced command line editing (readline) -o, --output=FILENAME send query results to file (or |pipe) -q, --quiet run quietly (no messages, only query output) -s, --single-step single-step mode (confirm each query) -S, --single-line single-line mode (end of line terminates SQL command)
Output format options: -A, --no-align unaligned table output mode --csv CSV (Comma-Separated Values) table output mode -F, --field-separator=STRING field separator for unaligned output (default: "|") -H, --html HTML table output mode -P, --pset=VAR[=ARG] set printing option VAR to ARG (see \pset command) -R, --record-separator=STRING record separator for unaligned output (default: newline) -t, --tuples-only print rows only -T, --table-attr=TEXT set HTML table tag attributes (e.g., width, border) -x, --expanded turn on expanded table output -z, --field-separator-zero set field separator for unaligned output to zero byte -0, --record-separator-zero set record separator for unaligned output to zero byte
Connection options: -h, --host=HOSTNAME database server host or socket directory (default: "local socket") -p, --port=PORT database server port (default: "5432") -U, --username=USERNAME database user name (default: "postgres") -w, --no-password never prompt for password -W, --password force password prompt (should happen automatically)
dropTABLE IF EXISTS company; CREATETABLE IF NOTEXISTS company ( id serial PRIMARY KEY, title CHAR(50) UNIQUENOTNULL, subtitle varchar(500) UNIQUENOTNULL, age INTNOTNULLDEFAULT0, address TEXT, salary REAL, money decimal, status double precision, guid uuid ); -- \d+ company insertinto company(name,address,age,salary) values('dennis','成都','28',3.14); insertinto company(name,address,age,salary) values('dennis1','成都','28',3.14); insertinto company(name,address,age,salary) values('dennis2','成都','28',3.14); insertinto company(name,address,age,salary) values('dennis3','成都','28',3.14); insertinto company(name,address,age,salary) values('dennis4','成都','28',3.14); insertinto company(name,address,age,salary) values('dennis5','成都','28',3.14); deletefrom company where age=28;
postgresql、mysql数据类型比较
postgresql
mysql
无
TINYINT
smallint(2字节)
SMALLINT(2字节)
无
MEDIUMINT(3字节)
integer(4字节)
INT或INTEGER(4字节)
bigint(8字节)
BIGINT(8字节)
decimal(可变长)
DECIMAL
numeric(可变长)
无
real(4字节)
FLOAT(4字节)
double(8字节)
DOUBLE(8字节)
character varying(n), varchar(n)
CHAR(0-255 bytes)
character(n), char(n)
VARCHAR(0-65535 byte)
无
TINYTEXT
text(无长度限制)
TEXT(0-65 535 bytes)
无
MEDIUMTEXT(0-16 777 215 bytes)
无
LONGTEXT(0-4 294 967 295 bytes)
timestamp(8字节)
TIMESTAMP(4字节)
date(4字节)
DATE(3字节)
time(8字节)
TIME(0-4 294 967 295 bytes)
interval(12字节)
无
smallserial(2字节)
无
serial(4字节)
无
bigserial(8字节)
无
json、jsonb数据类型
二者的区别在于json写入快,读取慢,jsonb写入慢
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
drop table if exists json_test; CREATE TABLE json_test ( id serial, board_id float NOT NULL, data jsonb ); INSERT INTO json_test VALUES (1, 1, '{"name": "Paint house", "tags": ["Improvements", "Office"], "finished": true}'); INSERT INTO json_test VALUES (2, 1, '{"name": "Wash dishes", "tags": ["Clean", "Kitchen"], "finished": false}'); INSERT INTO json_test VALUES (3, 1, '{"name": "Cook lunch", "tags": ["Cook", "Kitchen", "Tacos"], "ingredients": ["Tortillas", "Guacamole"], "finished": false}'); INSERT INTO json_test VALUES (4, 1, '{"name": "Vacuum", "tags": ["Clean", "Bedroom", "Office"], "finished": false}'); INSERT INTO json_test VALUES (5, 1, '{"name": "Hang paintings", "tags": ["Improvements", "Office"], "finished": false}'); SELECT data->>'name' AS name FROM json_test; SELECT * FROM json_test WHERE data->>'finished' = 'true';
insert into json_test select * from json_test;
vacuum full json_test
->将以JSON对象的形式返回该属性,而->>将以整数或文本
数组类型
在存储一些数据时能更节省空间
1 2 3 4 5 6 7 8 9 10 11
drop table if exists array_test; CREATE TABLE array_test ( id serial primary key, data int[] ); INSERT INTO array_test VALUES (1,'{3,5}'); select * from array_test; update array_test set data[0]=3434 where id=1; select * from array_test; update array_test set data[7]=3434 where id=1; select * from array_test;
SELECT procpid,START,now() -STARTAS lap,current_query FROM(SELECT backendid,pg_stat_get_backend_pid(S.backendid) AS procpid,pg_stat_get_backend_activity_start (S.backendid) ASSTART,pg_stat_get_backend_activity (S.backendid) AS current_query FROM(SELECT pg_stat_get_backend_idset () AS backendid) AS S) AS S WHERE current_query <>'<IDLE>'ORDERBY lap DESC;
配置相关接口
1 2 3 4 5
select name,setting from pg_settings where category='File Locations'; select name,setting from pg_settings; altersystemset log_statement='none'; SELECT pg_reload_conf(); show log_statement;
upsert
1
insertinto test values (1,'test',now()) on conflict(id) do updateset info=excluded.info,crt_time=excluded.crt_time;
select*from pg_statio_user_indexes; -- 查询索引内存命中率 select relname,relname,idx_blks_read,idx_blks_hit,idx_blks_hit*100/(idx_blks_read+idx_blks_hit) as idx_hit_rate from pg_statio_user_indexes;
select*from pg_statio_user_tables; -- 查询索引内存命中率 select heap_blks_read,heap_blks_hit,idx_blks_read,idx_blks_hit,heap_blks_hit*100/(heap_blks_hit+heap_blks_read) as heap_hit_rate,idx_blks_hit*100/(idx_blks_read+idx_blks_hit) as idx_hit_rate from pg_statio_user_tables;