From: Tomasz Myrta <jasiek@klaster.net>
To: Robert Treat <xzilla@users.sourceforge.net>
Cc: pgsql-performance@postgresql.org
Subject: Re: Slow query performance on large table
Date: Tue, 04 Mar 2003 18:29:30 +0100
Message-ID: <3E64E27A.3050708@klaster.net> (raw)
References: <000001c2e268$b1e47210$0c64a8c0@paulspc>
<1046797349.16957.20.camel@camel>
Robert Treat wrote:
> Maybe it's just me, but I get the feeling you need to work some regular
> reindexing into your maintenance schedule. Given your query is using
> between, I don't think it would use the index on the time field anyway
> (and explain analyze seems to be supporting this). Rewrite it so that
> you have a and time > foo and time < bar and I think you'll see a
> difference. With that in mind, I think your speedier query results are
> due more to having a non-bloated index freshly created than the fact
> that it being a dual column index.
>
> Robert Treat
Do you know anything about between, what should we know?
I made some tests, and there was no noticable difference between them:
pvwatch=# EXPLAIN analyze * from stats where hostid=1 and stp between 1
and 2;
QUERY PLAN
----------------------------------------------------------------------------------------------------------------
Index Scan using ind_stats on stats (cost=0.00..6.01 rows=1 width=28)
(actual time=0.00..0.00 rows=0 loops=1)
Index Cond: ((hostid = 1) AND (stp >= 1) AND (stp <= 2))
Total runtime: 0.00 msec
(3 rows)
pvwatch=# EXPLAIN analyze SELECT * from stats where hostid=1 and stp> 1
and stp<2;
QUERY PLAN
----------------------------------------------------------------------------------------------------------------
Index Scan using ind_stats on stats (cost=0.00..6.01 rows=1 width=28)
(actual time=0.00..0.00 rows=0 loops=1)
Index Cond: ((hostid = 1) AND (stp > 1) AND (stp < 2))
Total runtime: 0.00 msec
(3 rows)
Regards,
Tomasz Myrta
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: jasiek@klaster.net, xzilla@users.sourceforge.net
Subject: Re: Slow query performance on large table
In-Reply-To: <3E64E27A.3050708@klaster.net>
References: <000001c2e268$b1e47210$0c64a8c0@paulspc> <1046797349.16957.20.camel@camel> <3E64E27A.3050708@klaster.net>
* 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