ext2 VS ext3 性能测试: HP DL585 4 Dual Core 8222 processors 64GB RAM (2) MSA70 direct attached storage arrays. 25 spindles in each array (RAID 10) HP P800 Controller 6 Disk in RAID 10 on embedded controller
xlog with ext3: avg = 87418.44 KB/sec xlog with ext2: avg = 115375.34 KB/sec 3. Postgres 内存 (Memory Usage)
Shared Buffer Cache Working Memory Maintenance Memory Shared Buffers
working memory是per connection and per sort的设定。所以设定一定要非常小心。举例来说,如果设定working memory为32MB,那么以下例子: select * from lines, lineitems where lines.lineid = lineitems.lineid and lineid=6 order by baz; 这里就可 能用到64MB的内存。 hashjoin between lines and lineitems (32MB) order by baz (32MB) 要注意自己有多少query是用到了order by或者join 如果同时有100个链接,那么就是 100 connection X 64MB = 6400MB (6G) 内存 通常来说,working mem不要给太大,2-4MB足够
在postgres 8.3之后的版本,working mem可以在query中设定 Query: begin; set work_mem to ‘128MB’; select * from foo order by bar; insert into foo values (‘bar’); reset work_mem; commit; Function: create function return_foo() returns setof text as $ select * from foo order by bar; $ SET work_mem to ‘128MB’ LANGUAGE ’sql’
设定analyze分析的值。这个可以在 query中随时设定更改 set default_statistics_target to 100; analyze verbose mytable; INFO: analyzing “aweber_shoggoth.mytable” INFO: “mytable”: scanned 30000 of 1448084 pages, containing 1355449 live rows and 0 dead rows; 30000 rows in sample, 65426800 estimated total rows ANALYZE
set default_statistics_target to 300; analyze verbose mytable; INFO: analyzing “aweber_shoggoth.mytable” INFO: “mytable”: scanned 90000 of 1448084 pages, containing 4066431 live rows and 137 dead rows; 90000 rows in sample, 65428152 estimated total rows ANALYZE Set statistics per column 给不同的column设定不同的 statistics
alter table foo alter column bar set statistics 120 查找何时需要增加statistics
跑 个query作expain analyze 这个就会看到例如: -> Seq Scan on bar (cost=0.00-52.00 rows=52 width=2 (actual time=0.007..1.894 rows=3600 loops=1) 这里的rows应该跟真正的rows数量差不多才 是正确的。 seq_page_cost