![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||||||
| |||||||
|
|
Test Hardware: IBM Thinkpad R40 CPU: Pentium 4 Mobile 1993 Mhz (full powered) RAM: 512 MB OS: GNU/Linux, Fedora Core 1, kernel 2.4.24 A test program developed with libpq inserts 200.000 rows into table logs. Insertions are made with 100 row per transaction (total 2.000 transactions). Some parameter changes from postgresql.conf file follows: ---------------------------------------------------------------- shared_buffers = 2048 # min max_connections*2 or 16, 8KB each |
|
max_fsm_relations = 20000 # min 10, fsm is free space map, ~40 bytes max_fsm_pages = 200000 # min 1000, fsm is free space map, ~6 bytes max_locks_per_transaction = 256 # min 10 wal_buffers = 64 # min 4, typically 8KB each sort_mem = 32768 # min 64, size in KB |
|
vacuum_mem = 16384 # min 1024, size in KB |
|
effective_cache_size = 2000 # typically 8KB each |
|
The test was made with both of PostgreSQL 7.3.4 and PostgreSQL 7.4.1 (the test program was recompiled during version changes). The results are below (average inserted rows per second). speed for speed for # of EXISTING RECORDS PostgreSQL 7.3.4 PostgreSQL 7.4.1 ================================================== ======================= 0 initial records 1086 rows/s 1324 rows/s 200.000 initial records 781 rows/s 893 rows/s 400.000 initial records 576 rows/s 213 rows/s 600.000 initial records 419 rows/s 200 rows/s 800.000 initial records 408 rows/s not tested because of bad results |
|
When the logs table reconstructed with only one index (primary key) then 2941 rows/s speed is reached. But I need all the seven indexes. The question is why the PostgreSQL 7.4.1 is so slow under heavy work? |
|
Is there a way to speed up inserts without eliminating indexes? What about concurrent inserts (cocurrent spare test program execution) into the same table? It did not work. |
#3
| |||
| |||
|
|
Hello I need high throughput while inserting into PostgreSQL. Because of that I did some PostgreSQL insert performance tests. ------------------------------------------------------------ -- Test schema create table logs ( logid serial primary key, ctime integer not null, stime integer not null, itime integer not null, agentid integer not null, subagentid integer not null, ownerid integer not null, hostid integer not null, appname varchar(64) default null, logbody varchar(1024) not null ); create index ctime_ndx on logs using btree (ctime); create index stime_ndx on logs using btree (stime); create index itime_ndx on logs using btree (itime); create index agentid_ndx on logs using hash (agentid); create index ownerid_ndx on logs using hash (ownerid); create index hostid_ndx on logs using hash (hostid); ------------------------------------------------------------ Test Hardware: IBM Thinkpad R40 CPU: Pentium 4 Mobile 1993 Mhz (full powered) RAM: 512 MB OS: GNU/Linux, Fedora Core 1, kernel 2.4.24 A test program developed with libpq inserts 200.000 rows into table logs. Insertions are made with 100 row per transaction (total 2.000 transactions). Some parameter changes from postgresql.conf file follows: ---------------------------------------------------------------- shared_buffers = 2048 # min max_connections*2 or 16, 8KB each max_fsm_relations = 20000 # min 10, fsm is free space map, ~40 bytes max_fsm_pages = 200000 # min 1000, fsm is free space map, ~6 bytes max_locks_per_transaction = 256 # min 10 wal_buffers = 64 # min 4, typically 8KB each sort_mem = 32768 # min 64, size in KB vacuum_mem = 16384 # min 1024, size in KB checkpoint_segments = 6 # in logfile segments, min 1, 16MB each checkpoint_timeout = 900 # range 30-3600, in seconds fsync = true wal_sync_method = fsync # the default varies across platforms: enable_seqscan = true enable_indexscan = true enable_tidscan = true enable_sort = true enable_nestloop = true enable_mergejoin = true enable_hashjoin = true effective_cache_size = 2000 # typically 8KB each geqo = true geqo_selection_bias = 2.0 # range 1.5-2.0 geqo_threshold = 11 geqo_pool_size = 0 # default based on tables in statement, # range 128-1024 geqo_effort = 1 geqo_generations = 0 geqo_random_seed = -1 # auto-compute seed ---------------------------------------------------------------- The test was made with both of PostgreSQL 7.3.4 and PostgreSQL 7.4.1 (the test program was recompiled during version changes). The results are below (average inserted rows per second). speed for speed for # of EXISTING RECORDS PostgreSQL 7.3.4 PostgreSQL 7.4.1 ================================================== ======================= 0 initial records 1086 rows/s 1324 rows/s 200.000 initial records 781 rows/s 893 rows/s 400.000 initial records 576 rows/s 213 rows/s 600.000 initial records 419 rows/s 200 rows/s 800.000 initial records 408 rows/s not tested because of bad results When the logs table reconstructed with only one index (primary key) then 2941 rows/s speed is reached. But I need all the seven indexes. The question is why the PostgreSQL 7.4.1 is so slow under heavy work? Is there a way to speed up inserts without eliminating indexes? What about concurrent inserts (cocurrent spare test program execution) into the same table? It did not work. |
#4
| |||
| |||
|
|
create index agentid_ndx on logs using hash (agentid); create index ownerid_ndx on logs using hash (ownerid); create index hostid_ndx on logs using hash (hostid); ------------------------------------------------------------ speed for speed for # of EXISTING RECORDS PostgreSQL 7.3.4 PostgreSQL 7.4.1 ================================================== ======================= 0 initial records 1086 rows/s 1324 rows/s 200.000 initial records 781 rows/s 893 rows/s 400.000 initial records 576 rows/s 213 rows/s 600.000 initial records 419 rows/s 200 rows/s 800.000 initial records 408 rows/s not tested because of bad results |
#5
| |||
| |||
|
|
create index agentid_ndx on logs using hash (agentid); create index ownerid_ndx on logs using hash (ownerid); create index hostid_ndx on logs using hash (hostid); What about concurrent inserts (cocurrent spare test program execution) into the same table? It did not work. |
#6
| |||
| |||
|
|
I changed the three hash indexes to btree. The performance is increased about 2 times (in PostgreSQL 7.3.4 1905 rows/s). Concurrent inserts now work. |
|
Changed indexes are more suitable for hash type. |
#7
| |||
| |||
|
|
Sezai YILMAZ <sezai.yilmaz (AT) pro-g (DOT) com.tr> writes: I changed the three hash indexes to btree. The performance is increased about 2 times (in PostgreSQL 7.3.4 1905 rows/s). Concurrent inserts now work. Concurrent inserts should work with hash indexes in 7.4, though not 7.3. I notice this condition. I do not get dead locks with 7.4 on schema with |
|
The slowdown you report probably is due to the rewrite of hash indexing to allow more concurrency --- the locking algorithm is more complex than it used to be. I am surprised that the effect is so large though. Could you make your test program available? The test program and .SQL script is attached |
|
Changed indexes are more suitable for hash type. Are they? How many distinct values are there in those columns? I suspect that your test may be stressing the case where only a few hash buckets are used and each bucket chain gets to be very long. The biggest one gets 200 distinct values, the others are 5, and 10. More |
#8
| |||
| |||
|
|
Tom Lane wrote: Sezai YILMAZ <sezai.yilmaz (AT) pro-g (DOT) com.tr> writes: I changed the three hash indexes to btree. The performance is increased about 2 times (in PostgreSQL 7.3.4 1905 rows/s). Concurrent inserts now work. Concurrent inserts should work with hash indexes in 7.4, though not 7.3. I notice this condition. I do not get dead locks with 7.4 on schema with hash indexes. 7.4 solves this problem but is very slow. The slowdown you report probably is due to the rewrite of hash indexing to allow more concurrency --- the locking algorithm is more complex than it used to be. I am surprised that the effect is so large though. Could you make your test program available? The test program and .SQL script is attached Comiple and link scenarios: without transactions (where each insert is a transaction) $ gcc -o tester tester.c -lpq with default 400 inserts per transaction blocks $ gcc -DTRANSACTION -o tester tester.c -lpq with 200 inserts per transaction blocks $ gcc -DTRANSACTION -DINSERTPERTRANSACTION=200 -o tester tester.c -lpq I do concurrent tests by starting seperate tester programs from different xterm windows. |
#9
| |||
| |||
|
|
Everything default except for shared_buffers=100 and effective cache=25000, |
|
and I could not find sort_mem in postgresql.conf. Is work_mem new name for it? |
#10
| |||
| |||
|
|
Shridhar Daithankar <shridhar (AT) frodo (DOT) hserus.net> writes: Everything default except for shared_buffers=100 and effective cache=25000, 100? |
![]() |
| Thread Tools | |
| Display Modes | |
| |