From: David Teran <david.teran@cluster9.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-performance@postgresql.org
Subject: Re: optimizing Postgres queries
Date: Mon, 5 Jan 2004 20:20:49 +0100
Message-ID: <4530AF9E-3FB4-11D8-A528-000A95A6F0DC@cluster9.com> (raw)
In-Reply-To: <20540.1073329548@sss.pgh.pa.us>
References: <4B0023AC-3F72-11D8-B3EB-000A95A6F0DC@cluster9.com>
<200401051705.55120.shridhar_daithankar@myrealbox.com>
<64C8DBBA-3F77-11D8-A528-000A95A6F0DC@cluster9.com>
<200401051740.05006.shridhar_daithankar@myrealbox.com>
<3796212E-3F79-11D8-A528-000A95A6F0DC@cluster9.com>
<9966.1073316152@sss.pgh.pa.us>
<9CC6A792-3FAF-11D8-A528-000A95A6F0DC@cluster9.com>
<16230.1073328760@sss.pgh.pa.us>
<A5055773-3FB1-11D8-A528-000A95A6F0DC@cluster9.com>
<20540.1073329548@sss.pgh.pa.us>
Hi Tom,
first of all thanks for your help! I really appreciate your fast
response and if you ever have a question about WebObjects, just drop me
line ;-)
>> Seq Scan on "KEY_VALUE_META_DATA" t0 (cost=0.00..2671.16 rows=931
>> width
>> =1068) (actual time=122.669..172.179 rows=25 loops=1)
>> Filter: (("ID_VALUE" = 21094) OR ("ID_VALUE" = 21103))
>
> The problem is evidently that the row estimate is so far off (931
> estimate vs 25 actual). Have you done ANALYZE or VACUUM ANALYZE
> on this table recently? If you have, I'd be interested to see the
> pg_stats row for ID_VALUE. It might be that you need to increase
> the statistics target for this table.
>
I am absolutely new to PostgreSQL. OK, after VACUUM ANALYZE i get:
Index Scan using key_value_meta_data__id_value__fk_index, key_value_meta
_data__id_value__fk_index on "KEY_VALUE_META_DATA" t0 (cost=0.00..19.94
rows=14 width=75) (actual time=0.615..1.017 rows=25 loops=1)
Index Cond: (("ID_VALUE" = 21094) OR ("ID_VALUE" = 21103))
Total runtime: 2.565 ms
and the second time i invoke this i get
Index Scan using key_value_meta_data__id_value__fk_index, key_value_meta
_data__id_value__fk_index on "KEY_VALUE_META_DATA" t0 (cost=0.00..19.94
rows=14 width=75) (actual time=0.112..0.296 rows=25 loops=1)
Index Cond: (("ID_VALUE" = 21094) OR ("ID_VALUE" = 21103))
Total runtime: 0.429 ms
Much better. So i think i will first read more about this optimization
stuff and regular maintenance things. This is something i like very
much from FrontBase: no need for such things, simply start and run. But
other things were not so fine ;-).
Is there any hint where to start to understand more about this
optimization problem?
regards David
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: david.teran@cluster9.com, tgl@sss.pgh.pa.us
Subject: Re: optimizing Postgres queries
In-Reply-To: <4530AF9E-3FB4-11D8-A528-000A95A6F0DC@cluster9.com>
References: <4B0023AC-3F72-11D8-B3EB-000A95A6F0DC@cluster9.com> <200401051705.55120.shridhar_daithankar@myrealbox.com> <64C8DBBA-3F77-11D8-A528-000A95A6F0DC@cluster9.com> <200401051740.05006.shridhar_daithankar@myrealbox.com> <3796212E-3F79-11D8-A528-000A95A6F0DC@cluster9.com> <9966.1073316152@sss.pgh.pa.us> <9CC6A792-3FAF-11D8-A528-000A95A6F0DC@cluster9.com> <16230.1073328760@sss.pgh.pa.us> <A5055773-3FB1-11D8-A528-000A95A6F0DC@cluster9.com> <20540.1073329548@sss.pgh.pa.us> <4530AF9E-3FB4-11D8-A528-000A95A6F0DC@cluster9.com>
* 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