473,407 Members | 2,314 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Tunning postgresql

Hello list,

I have 7.3.4 on RH 8, server hardware is a dual processor Intel Xeon 2.4
Ghz, 2G RAM. I was reading about tunning and would like to get some help
from you, I changed some of the default values and the performance
increased a little but I think still I can get more from that box.

What should be the right values to set in kernel and postgresql.conf to
get maximum performance, actually kernel share memory is:
cat /proc/sys/kernel/shmmax
268435456
cat /proc/sys/kernel/shmall
268435456

postgresql.conf contains these configurations modified:

shared_buffers = 17000 # min max_connections*2 or 16, 8KB each
max_fsm_relations = 400 # min 10, fsm is free space map, ~40
max_fsm_pages = 80000 # min 1000, fsm is free space map, ~6
max_locks_per_transaction = 64 # min 10
sort_mem = 16384 # min 64, size in KB
effective_cache_size = 1700000 # typically 8KB each

Still don't understand very well how to combine these parameters to gain
maximun performance for postgresql, any help or comment about this
would be very appreciated.

Thanks,
--
Josué Maldonado.

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 12 '05 #1
10 4889
On Wed, 2003-11-19 at 14:25, JosuƩ Maldonado wrote:
Hello list,

I have 7.3.4 on RH 8, server hardware is a dual processor Intel Xeon 2.4
Ghz, 2G RAM. I was reading about tunning and would like to get some help
from you, I changed some of the default values and the performance
increased a little but I think still I can get more from that box.

What should be the right values to set in kernel and postgresql.conf to
get maximum performance, actually kernel share memory is:
cat /proc/sys/kernel/shmmax
268435456
cat /proc/sys/kernel/shmall
268435456

postgresql.conf contains these configurations modified:

shared_buffers = 17000 # min max_connections*2 or 16, 8KB each
max_fsm_relations = 400 # min 10, fsm is free space map, ~40
max_fsm_pages = 80000 # min 1000, fsm is free space map, ~6
max_locks_per_transaction = 64 # min 10
sort_mem = 16384 # min 64, size in KB
effective_cache_size = 1700000 # typically 8KB each

Still don't understand very well how to combine these parameters to gain
maximun performance for postgresql, any help or comment about this
would be very appreciated.

Thanks,


Speaking from long experimentation, you're much, much better off making
sure your indices and queries are optimal that messing around with
buffer space. Buffer space tuning might get you a few percent
performance once you pick a reasonable value; query tuning can get you
orders of magnitude.

Stephen
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 12 '05 #2


Josué Maldonado wrote:
Hello list,
postgresql.conf contains these configurations modified:

shared_buffers = 17000 # min max_connections*2 or 16, 8KB each
max_fsm_relations = 400 # min 10, fsm is free space map, ~40
max_fsm_pages = 80000 # min 1000, fsm is free space map, ~6
max_locks_per_transaction = 64 # min 10
sort_mem = 16384 # min 64, size in KB
effective_cache_size = 1700000 # typically 8KB each

These seem pretty reasonable... apart from the effective cache size,
maybe chop off a zero :

effective_cache_size = 170000 # about 1.2G

I wonder if the original setting, 6 times your ram (if my arithmetic is
ok) *may* result in funny optimizer choices....

The thing to do next is examine EXPLAIN outputs for your queries, and
consider what smarter access plans might be possible (e.g. indexes,
partial indexes) and then maybe clever data re-orgizations (e.g.
clusters, trigger based summaries of aggregates) if you still need more
speed.

regards

Mark
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 12 '05 #3
Hi Stephen,

Stephen Robert Norris wrote:


Speaking from long experimentation, you're much, much better off making
sure your indices and queries are optimal that messing around with
buffer space. Buffer space tuning might get you a few percent
performance once you pick a reasonable value; query tuning can get you
orders of magnitude.


I tunned my querys and all uses indexes and seems to be fast, but when
my client app acccess the pg data it seems a little slow. I installed
MSDE (mssql limited version) and copied the same data from pg to MSDE, I
was surprised cuz running the same query with the same data and MSDE
seems to be a little bit faster, after the changes in postgresql.conf
described in the previus message pg perfomance increased a little but
still there is no big difference against MSDE, considering hardware, pg
is in a real server (dual Xeon 2.4 Ghz, 2G RAM, 3 36G SCSI drives on a
RAID5) and the server is not in production, MSDE is in a AMD athlon 1Gh
with 256RAM y should expect better performace from pg. I wonder if ODBC
could be affect performance so high, my current ODBC driver is 7.03.02.

Thanks

--
JosuƩ Maldonado.

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 12 '05 #4
On Thu, 2003-11-20 at 02:06, JosuƩ Maldonado wrote:
Hi Stephen,

Stephen Robert Norris wrote:


Speaking from long experimentation, you're much, much better off making
sure your indices and queries are optimal that messing around with
buffer space. Buffer space tuning might get you a few percent
performance once you pick a reasonable value; query tuning can get you
orders of magnitude.


I tunned my querys and all uses indexes and seems to be fast, but when
my client app acccess the pg data it seems a little slow. I installed
MSDE (mssql limited version) and copied the same data from pg to MSDE, I
was surprised cuz running the same query with the same data and MSDE
seems to be a little bit faster, after the changes in postgresql.conf
described in the previus message pg perfomance increased a little but
still there is no big difference against MSDE, considering hardware, pg
is in a real server (dual Xeon 2.4 Ghz, 2G RAM, 3 36G SCSI drives on a
RAID5) and the server is not in production, MSDE is in a AMD athlon 1Gh
with 256RAM y should expect better performace from pg. I wonder if ODBC
could be affect performance so high, my current ODBC driver is 7.03.02.

Thanks


I have never used ODBC so I don't know how much that will effect
performance. What are the schemata for the tables, and what does explain
analyze tell you about the query?

Stephen
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 12 '05 #5
Stephen,

This is the query code:
SELECT
(cmes(substr(epr_periodo,5,2))||'-'||substr(epr_periodo,3,2))::char(6)
AS hmes,
epr_periodo,
coalesce(epr_venta,0)::numeric(12,4) as epr_venta,
coalesce(epr_costo,0)::numeric(12,4) as epr_costo,
coalesce(epr_qty,0)::numeric(12,4) as epr_qty,
coalesce(epr_qty2,0)::numeric(12,4) as epr_qty2,
coalesce(epr_qty3,0)::numeric(12,4) as epr_qty3,
case when epr_qty=0 then 0 else
coalesce((epr_costo/epr_qty),0)::numeric(12,4)
end as cost_prom,
case when epr_qty=0 then 0 else
coalesce((epr_venta/epr_qty),0)::numeric(12,4)
end as prec_prom,
case when epr_costo=0 then 0 else
coalesce((((epr_venta/epr_costo)*100)-100),0)::numeric(12,4)
end as margen
FROM estprod WHERE pro_code = '1017' and epr_periodo >= '200211' and
epr_periodo <= '200311'

This is the explain:
Index Scan using idx_estx on estprod (cost=0.00..38.29 rows=9 width=67)
(actual time=0.52..1.64 rows=13 loops=1)
Index Cond: ((pro_code = '1017'::bpchar) AND (epr_periodo >=
'200211'::bpchar) AND (epr_periodo <= '200311'::bpchar))
Total runtime: 1.70 msec
(3 rows)
Table estprod is:
CREATE TABLE public.estprod
(
pk_estprod int4 DEFAULT nextval('sqestprod'::text),
product_fk int4,
epr_periodo char(6),
epr_venta numeric(12,4),
epr_costo numeric(12,4),
epr_qty numeric(12,4),
epr_venta2 numeric(12,4),
epr_costo2 numeric(12,4),
epr_qty2 numeric(12,4),
epr_venta3 numeric(12,4),
epr_costo3 numeric(12,4),
epr_qty3 numeric(12,4),
epr_ventax numeric(12,2),
pro_code char(4),
xmes varchar(6),
imes int4
) WITH OIDS;

and it contains 355,513 rows

Stephen Robert Norris wrote:
On Thu, 2003-11-20 at 02:06, JosuƩ Maldonado wrote:
Hi Stephen,

Stephen Robert Norris wrote:

Speaking from long experimentation, you're much, much better off making
sure your indices and queries are optimal that messing around with
buffer space. Buffer space tuning might get you a few percent
performance once you pick a reasonable value; query tuning can get you
orders of magnitude.


I tunned my querys and all uses indexes and seems to be fast, but when
my client app acccess the pg data it seems a little slow. I installed
MSDE (mssql limited version) and copied the same data from pg to MSDE, I
was surprised cuz running the same query with the same data and MSDE
seems to be a little bit faster, after the changes in postgresql.conf
described in the previus message pg perfomance increased a little but
still there is no big difference against MSDE, considering hardware, pg
is in a real server (dual Xeon 2.4 Ghz, 2G RAM, 3 36G SCSI drives on a
RAID5) and the server is not in production, MSDE is in a AMD athlon 1Gh
with 256RAM y should expect better performace from pg. I wonder if ODBC
could be affect performance so high, my current ODBC driver is 7.03.02.

Thanks

I have never used ODBC so I don't know how much that will effect
performance. What are the schemata for the tables, and what does explain
analyze tell you about the query?

Stephen

--
JosuƩ Maldonado.

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 12 '05 #6
On Thu, 2003-11-20 at 10:20, JosuƩ Maldonado wrote:
Stephen,

This is the query code:
SELECT
(cmes(substr(epr_periodo,5,2))||'-'||substr(epr_periodo,3,2))::char(6)
AS hmes,
epr_periodo,
coalesce(epr_venta,0)::numeric(12,4) as epr_venta,
coalesce(epr_costo,0)::numeric(12,4) as epr_costo,
coalesce(epr_qty,0)::numeric(12,4) as epr_qty,
coalesce(epr_qty2,0)::numeric(12,4) as epr_qty2,
coalesce(epr_qty3,0)::numeric(12,4) as epr_qty3,
case when epr_qty=0 then 0 else
coalesce((epr_costo/epr_qty),0)::numeric(12,4)
end as cost_prom,
case when epr_qty=0 then 0 else
coalesce((epr_venta/epr_qty),0)::numeric(12,4)
end as prec_prom,
case when epr_costo=0 then 0 else
coalesce((((epr_venta/epr_costo)*100)-100),0)::numeric(12,4)
end as margen
FROM estprod WHERE pro_code = '1017' and epr_periodo >= '200211' and
epr_periodo <= '200311'

This is the explain:
Index Scan using idx_estx on estprod (cost=0.00..38.29 rows=9 width=67)
(actual time=0.52..1.64 rows=13 loops=1)
Index Cond: ((pro_code = '1017'::bpchar) AND (epr_periodo >=
'200211'::bpchar) AND (epr_periodo <= '200311'::bpchar))
Total runtime: 1.70 msec
(3 rows)


This looks pretty good - 1.7ms is very quick for a query. If you're
seeing performance problems, it must be from the ODBC layer.

Stephen
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)

Nov 12 '05 #7
On Thu, 2003-11-20 at 02:06, JosuƩ Maldonado wrote:
Hi Stephen,

Stephen Robert Norris wrote:


Speaking from long experimentation, you're much, much better off making
sure your indices and queries are optimal that messing around with
buffer space. Buffer space tuning might get you a few percent
performance once you pick a reasonable value; query tuning can get you
orders of magnitude.


I tunned my querys and all uses indexes and seems to be fast, but when
my client app acccess the pg data it seems a little slow. I installed
MSDE (mssql limited version) and copied the same data from pg to MSDE, I
was surprised cuz running the same query with the same data and MSDE
seems to be a little bit faster, after the changes in postgresql.conf
described in the previus message pg perfomance increased a little but
still there is no big difference against MSDE, considering hardware, pg
is in a real server (dual Xeon 2.4 Ghz, 2G RAM, 3 36G SCSI drives on a
RAID5) and the server is not in production, MSDE is in a AMD athlon 1Gh
with 256RAM y should expect better performace from pg. I wonder if ODBC
could be affect performance so high, my current ODBC driver is 7.03.02.

Thanks


I have never used ODBC so I don't know how much that will effect
performance. What are the schemata for the tables, and what does explain
analyze tell you about the query?

Stephen
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 12 '05 #8
Stephen,

This is the query code:
SELECT
(cmes(substr(epr_periodo,5,2))||'-'||substr(epr_periodo,3,2))::char(6)
AS hmes,
epr_periodo,
coalesce(epr_venta,0)::numeric(12,4) as epr_venta,
coalesce(epr_costo,0)::numeric(12,4) as epr_costo,
coalesce(epr_qty,0)::numeric(12,4) as epr_qty,
coalesce(epr_qty2,0)::numeric(12,4) as epr_qty2,
coalesce(epr_qty3,0)::numeric(12,4) as epr_qty3,
case when epr_qty=0 then 0 else
coalesce((epr_costo/epr_qty),0)::numeric(12,4)
end as cost_prom,
case when epr_qty=0 then 0 else
coalesce((epr_venta/epr_qty),0)::numeric(12,4)
end as prec_prom,
case when epr_costo=0 then 0 else
coalesce((((epr_venta/epr_costo)*100)-100),0)::numeric(12,4)
end as margen
FROM estprod WHERE pro_code = '1017' and epr_periodo >= '200211' and
epr_periodo <= '200311'

This is the explain:
Index Scan using idx_estx on estprod (cost=0.00..38.29 rows=9 width=67)
(actual time=0.52..1.64 rows=13 loops=1)
Index Cond: ((pro_code = '1017'::bpchar) AND (epr_periodo >=
'200211'::bpchar) AND (epr_periodo <= '200311'::bpchar))
Total runtime: 1.70 msec
(3 rows)
Table estprod is:
CREATE TABLE public.estprod
(
pk_estprod int4 DEFAULT nextval('sqestprod'::text),
product_fk int4,
epr_periodo char(6),
epr_venta numeric(12,4),
epr_costo numeric(12,4),
epr_qty numeric(12,4),
epr_venta2 numeric(12,4),
epr_costo2 numeric(12,4),
epr_qty2 numeric(12,4),
epr_venta3 numeric(12,4),
epr_costo3 numeric(12,4),
epr_qty3 numeric(12,4),
epr_ventax numeric(12,2),
pro_code char(4),
xmes varchar(6),
imes int4
) WITH OIDS;

and it contains 355,513 rows

Stephen Robert Norris wrote:
On Thu, 2003-11-20 at 02:06, JosuƩ Maldonado wrote:
Hi Stephen,

Stephen Robert Norris wrote:

Speaking from long experimentation, you're much, much better off making
sure your indices and queries are optimal that messing around with
buffer space. Buffer space tuning might get you a few percent
performance once you pick a reasonable value; query tuning can get you
orders of magnitude.


I tunned my querys and all uses indexes and seems to be fast, but when
my client app acccess the pg data it seems a little slow. I installed
MSDE (mssql limited version) and copied the same data from pg to MSDE, I
was surprised cuz running the same query with the same data and MSDE
seems to be a little bit faster, after the changes in postgresql.conf
described in the previus message pg perfomance increased a little but
still there is no big difference against MSDE, considering hardware, pg
is in a real server (dual Xeon 2.4 Ghz, 2G RAM, 3 36G SCSI drives on a
RAID5) and the server is not in production, MSDE is in a AMD athlon 1Gh
with 256RAM y should expect better performace from pg. I wonder if ODBC
could be affect performance so high, my current ODBC driver is 7.03.02.

Thanks

I have never used ODBC so I don't know how much that will effect
performance. What are the schemata for the tables, and what does explain
analyze tell you about the query?

Stephen

--
JosuƩ Maldonado.

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 12 '05 #9
On Thu, 2003-11-20 at 10:20, JosuƩ Maldonado wrote:
Stephen,

This is the query code:
SELECT
(cmes(substr(epr_periodo,5,2))||'-'||substr(epr_periodo,3,2))::char(6)
AS hmes,
epr_periodo,
coalesce(epr_venta,0)::numeric(12,4) as epr_venta,
coalesce(epr_costo,0)::numeric(12,4) as epr_costo,
coalesce(epr_qty,0)::numeric(12,4) as epr_qty,
coalesce(epr_qty2,0)::numeric(12,4) as epr_qty2,
coalesce(epr_qty3,0)::numeric(12,4) as epr_qty3,
case when epr_qty=0 then 0 else
coalesce((epr_costo/epr_qty),0)::numeric(12,4)
end as cost_prom,
case when epr_qty=0 then 0 else
coalesce((epr_venta/epr_qty),0)::numeric(12,4)
end as prec_prom,
case when epr_costo=0 then 0 else
coalesce((((epr_venta/epr_costo)*100)-100),0)::numeric(12,4)
end as margen
FROM estprod WHERE pro_code = '1017' and epr_periodo >= '200211' and
epr_periodo <= '200311'

This is the explain:
Index Scan using idx_estx on estprod (cost=0.00..38.29 rows=9 width=67)
(actual time=0.52..1.64 rows=13 loops=1)
Index Cond: ((pro_code = '1017'::bpchar) AND (epr_periodo >=
'200211'::bpchar) AND (epr_periodo <= '200311'::bpchar))
Total runtime: 1.70 msec
(3 rows)


This looks pretty good - 1.7ms is very quick for a query. If you're
seeing performance problems, it must be from the ODBC layer.

Stephen
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)

Nov 12 '05 #10
Stephen Robert Norris wrote:

This looks pretty good - 1.7ms is very quick for a query. If you're
seeing performance problems, it must be from the ODBC layer.

I recall striking this sort of problem with old Oracle ODBC drivers - we
used to set "Pass Through" mode for all the queries. However, I am don't
know if the Pg driver supports it (or if it would actually help
significantly).

Might be worth trying out some other ODBC drivers for Pg. I am pretty
sure there are some, however I can recall the brands :-(

regards

Mark
---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 12 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Otis Green | last post by:
Vote for or against a new newsgroup proposal. To summarize what you need to do, just send an empty e-mail to postgresql-ballot@netagw.com You will receive a ballot by e-mail. Follow the...
0
by: Bill J. | last post by:
I have to update a PostgreSQL linked server through MSSQL2K. I first configured the connection with ODBC as follows and I can do queries with no problem: EXEC sp_droplinkedsrvlogin @rmtsrvname...
0
by: Bill J. | last post by:
I have to update a PostgreSQL linked server through MSSQL2K. I first configured the connection with ODBC as follows and I can do queries with no problem: EXEC sp_droplinkedsrvlogin @rmtsrvname...
0
by: Greg Sabino Mullane | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 This is a PGP-signed copy of the checksums for following PostgreSQL versions: 7.4.5 7.4.4 7.3.7
1
by: rmli | last post by:
Expert tunning Database http://quickdba.blogspot.com/2006/05/oracle-expert-tuning-secrets_22.html
4
by: Raj | last post by:
Hi all, I need help tunning the following query Table scan on table Fact.sale_Current_2005 1.select key,sale_amt,dt,c4,c5,c6,c7 from Fact.sale_Current_view where dt>= (select (min(Dt))...
0
by: keysac | last post by:
Hi , My belwo script takes long time to run. What can i do about its performance tunning. This scripts read values from table t_emp . It search for that empid ie comp_guid across the database . ie...
1
by: tpramarao | last post by:
I want know how to implement index tunning by using index tunning wizard.can any body help me regarding this problem. thanks, pattabi
1
by: vijaysonar29 | last post by:
Dear all , As I am going through maintainance phase of my project ,currently working on oracle9i,I nees some Articles,docs,whitepaper,weblink,pdf etc regarding SQL tunning,Anything which is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.