30
Производительность PostgreSQL Николай Самохвалов http://postgresmen.ru

Highload++ 2008: Производительность PostgreSQL, Николай Самохвалов

Embed Size (px)

Citation preview

PostgreSQL http://postgresmen.ru

PostgreSQL ; BSD-; , , ACID ; ;

http://samokhvalov.com/files/20081006_highload2008_postgresql.pdf

PostgreSQL : email:[email protected] xmpp:[email protected] , web:http://postgresmen.ru ; : -: http://wiki.postgresmen.ru/index.php/-_PostgreSQL;http://samokhvalov.com/files/20081006_highload2008_postgresql.pdf

http://wiki.postgresql.org/wiki/Development_information;

PostgreSQL : wikipedia (.); : , , , ;

http://samokhvalov.com/files/20081006_highload2008_postgresql.pdf

:tikaonline.de

PostgreSQL : , M-S, M-M , , PL/Proxy, GridSQL.

:tikaonline.de

http://samokhvalov.com/files/20081006_highload2008_postgresql.pdf

1. 2.

http://samokhvalov.com/files/20081006_highload2008_postgresql.pdf

, RAID, , , postgresql.conf

? ( 0)

http://samokhvalov.com/files/20081006_highload2008_postgresql.pdf

?

http://samokhvalov.com/files/20081006_highload2008_postgresql.pdf

, ! ( )

: contrib/pgbench, bonnie++ , , web-: ZABBIX, + Cacti/Nagios, Staplr by Gavin Roy SQL-: pgFouine; pg_stat_*, reads/hits, phpPgAdmin

http://samokhvalov.com/files/20081006_highload2008_postgresql.pdf

?

!

PostgreSQLHardwarePerformanceTuning byBruceMomjian(.), Highload2007

http://samokhvalov.com/files/20081006_highload2008_postgresql.pdf

DBA

8.28.3

http://samokhvalov.com/files/20081006_highload2008_postgresql.pdf

DBA

pgBouncer()

http://samokhvalov.com/files/20081006_highload2008_postgresql.pdf

DBA

RAM:

http://samokhvalov.com/files/20081006_highload2008_postgresql.pdf

DBA

: LA

http://samokhvalov.com/files/20081006_highload2008_postgresql.pdf

*FreeBSDnode

: 1: !shared_buffers work_mem max_connections effective_cache_size

VACUUM, FSM, , checkpoints 187 3- (Josh Berkus)

: , http://samokhvalov.com/files/20081006_highload2008_postgresql.pdf

: 2: PgBouncer

http://samokhvalov.com/files/20081006_highload2008_postgresql.pdf

: 3 ( ):statement_timeout=90s

:SETstatement_timeoutTO0;

ALTERUSERmaintanance_userSETstatement_timeoutTO0;

http://samokhvalov.com/files/20081006_highload2008_postgresql.pdf

: 3: SELECT datname, CASE WHEN blks_read = 0 THEN 0 ELSE blks_hit / blks_read END AS ratio FROM pg_stat_database; SELECT indexrelname, idx_tup_read, idx_tup_fetch, (idx_tup_read - idx_tup_fetch), CASE WHEN idx_tup_read = 0 THEN 0 ELSE (idx_tup_read::float4 idx_tup_fetch) / idx_tup_read END as r FROM pg_stat_user_indexes ORDER BY r desc;

.....

(,,..)http://samokhvalov.com/files/20081006_highload2008_postgresql.pdf

:tikaonline.de

, SQL-, , , ,

? ( 0)

http://samokhvalov.com/files/20081006_highload2008_postgresql.pdf

?

!http://samokhvalov.com/files/20081006_highload2008_postgresql.pdf

: 1. , : , , , (, hit/read), EXPLAIN ANALYZE; 2. PgFouine

http://samokhvalov.com/files/20081006_highload2008_postgresql.pdf

PgFouine [] :

. Queries that took up the most time (N), , > 1h !

, ;

http://samokhvalov.com/files/20081006_highload2008_postgresql.pdf

PgFouine

80-90% ? ;-)

SQL-; TPS-

http://samokhvalov.com/files/20081006_highload2008_postgresql.pdf

PgFouine

VACUUMVERBOSE FSM /, Tsung:

http://samokhvalov.com/files/20081006_highload2008_postgresql.pdf

PgFouinepostgresql.conf: log_min_duration_statement=100ms : ! 1s, 100ms pgFouine PHP (sic!). , RAM.http://samokhvalov.com/files/20081006_highload2008_postgresql.pdf

: 1: PostgreSQL

B-Tree, GiST, R-Tree, GIN; : btree 2 , : btree_gist+rtree, rtree+ btree_gist+GiST(.) .. 1 (!) : CREATEINDEXidxONt1(substr(name,6)); CREATEINDEXidsONt1WHEREstatus=1;

http://samokhvalov.com/files/20081006_highload2008_postgresql.pdf

: 2:

OUTER (LEFT/RIGHT) JOIN GROUP BY, DISTINCT, DISTINCT ON, UNION ( ALL) ... OFFSET 100000; SELECT COUNT(1) FROM t1 WHERE ... AND ... AND ...;

http://samokhvalov.com/files/20081006_highload2008_postgresql.pdf

: 2: . ( ): 1: count() ( : 1000000 ): ( EXPLAINSELECT...); 2: OFFSET: , ( GMail), , .http://samokhvalov.com/files/20081006_highload2008_postgresql.pdf

: 3:

SQL-; ; : Slony-I ( ), SkyTools, PL/Proxy, GridSQL.

: ! Skype; myYearbook.com.http://samokhvalov.com/files/20081006_highload2008_postgresql.pdf

30 .

?) ; ) 19:00 PostgreSQL-; ) . email:[email protected]:[email protected] web:http://postgresmen.ru http://samokhvalov.com/files/20081006_highload2008_postgresql.pdf