From: David Leangen <postgres@leangen.net>
To: pgsql-performance@postgresql.org
Subject: Improving query performance
Date: Fri, 02 Mar 2007 13:00:30 +0900
Message-ID: <1172808030.27446.12.camel@sonoda.bioscene.co.jp> (raw)
Hello!
I'm new to performance tuning on postgres. I've read the docs on the
posgtres site, as well as:
http://www.revsys.com/writings/postgresql-performance.htmlhttp://www.powerpostgresql.com/PerfList
However, my query is really slow, and I'm not sure what the main cause
could be, as there are so many variables. I'm hoping people with more
experience could help out.
My machine has 8Gb RAM, 2xCPU (2Gz, I think...)
Table has about 1M rows.
This is my postgres.conf:
listen_addresses = '*'
port = 5432
max_connections = 100
shared_buffers = 256000
effective_cache_size = 1000000
work_mem = 5000000
redirect_stderr = on
log_directory = 'pg_log'
log_filename = 'postgresql-%a.log'
log_truncate_on_rotation = on
log_rotation_age = 1440
log_rotation_size = 0
lc_messages = 'en_US.UTF-8'
lc_monetary = 'en_US.UTF-8'
lc_numeric = 'en_US.UTF-8'
lc_time = 'en_US.UTF-8'
This is the result of "explain analyze":
Aggregate (cost=384713.17..384713.18 rows=1 width=4) (actual
time=254856.025..254856.025 rows=1 loops=1)
-> Seq Scan on medline_articles t0 (cost=0.00..382253.00
rows=984068 width=4) (actual time=511.841..254854.981 rows=788 loops=1)
Filter: long_ugly_query_here
And this is the actual query:
SELECT COUNT(t0.ID) FROM public.MY_TABLE t0
WHERE ((POSITION('adenosine cyclic 35-monophosphate' IN LOWER(t0.TITLE))
- 1) >=0 OR
(POSITION('adenosine cyclic 55-monophosphate' IN LOWER(t0.TEXT)) - 1) >=
0 OR
(POSITION('cyclic amp, disodium salt' IN LOWER(t0.TITLE)) - 1) >= 0 OR
(POSITION('cyclic amp, disodium salt' IN LOWER(t0.TEXT)) - 1) >= 0 OR
(POSITION('cyclic amp, sodium salt' IN LOWER(t0.TEXT)) - 1) >= 0 OR
(POSITION('cyclic amp, sodium salt' IN LOWER(t0.TITLE)) - 1) >= 0 OR
(POSITION('cyclic amp' IN LOWER(t0.TEXT)) - 1) >= 0 OR
(POSITION('cyclic amp' IN LOWER(t0.TITLE)) - 1) >= 0 OR
(POSITION('cyclic amp, monopotassium salt' IN LOWER(t0.TEXT)) - 1) >= 0
OR
(POSITION('cyclic amp, monopotassium salt' IN LOWER(t0.TEXT)) - 1) >= 0
OR
(POSITION('adenosine cyclic-35-monophosphate' IN LOWER(t0.TEXT)) - 1) >=
0 OR
(POSITION('adenosine cyclic-35-monophosphate' IN LOWER(t0.TITLE)) - 1)
>= 0 OR
(POSITION('adenosine cyclic monophosphate' IN LOWER(t0.TEXT)) - 1) >= 0
OR
(POSITION('adenosine cyclic monophosphate' IN LOWER(t0.TITLE)) - 1) >= 0
OR
(POSITION('cyclic amp, monoammonium salt' IN LOWER(t0.TEXT)) - 1) >= 0
OR
(POSITION('cyclic amp, monoammonium salt' IN LOWER(t0.TITLE)) - 1) >= 0
OR
(POSITION('adenosine cyclic 3,5 monophosphate' IN LOWER(t0.TEXT)) - 1)
>= 0 OR
(POSITION('adenosine cyclic 3,5 monophosphate' IN LOWER(t0.TITLE)) - 1)
>= 0 OR
(POSITION('cyclic amp, monosodium salt' IN LOWER(t0.TEXT)) - 1) >= 0 OR
(POSITION('cyclic amp, monosodium salt' IN LOWER(t0.TITLE)) - 1) >= 0
OR
(POSITION('cyclic amp, (r)-isomer' IN LOWER(t0.TEXT)) - 1) >= 0 OR
(POSITION('cyclic amp, (r)-isomer' IN LOWER(t0.TEXT)) - 1) >= 0)
Some more info:
pubmed=> SELECT relpages, reltuples FROM pg_class WHERE relname =
'MY_TABLE';
relpages | reltuples
----------+-----------
155887 | 984200
(1 row)
Thanks for any suggestions!
Dave
PS - Yes! I did run "vacuum analyze" :-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-performance@postgresql.org
Cc: postgres@leangen.net
Subject: Re: Improving query performance
In-Reply-To: <1172808030.27446.12.camel@sonoda.bioscene.co.jp>
References: <1172808030.27446.12.camel@sonoda.bioscene.co.jp>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox