From: Shridhar Daithankar <shridhar_daithankar@persistent.co.in>
To: pgsql-performance@postgresql.org
Subject: Re: any way to use indexscan to get last X values with "order by Y limit X" clause?
Date: Sun, 15 Jun 2003 20:01:38 +0530
Message-ID: <3EECD0A2.8545.2FA1D9@localhost> (raw)
In-Reply-To: <5.2.1.1.0.20030615161722.025c7630@127.0.0.1>
On 15 Jun 2003 at 16:26, Tomaz Borstnar wrote:
>
> Here is the structure:
<snip>
> approved | character(1) | not null default 'N'
> msgid | character(100) | not null default ''
> modifystamp | integer | not null default '0'
> userid | integer | not null default '0'
> closed | smallint | default '0'
> Indexes: tjavendanpri_key primary key btree (id),
> tjavendan_approved btree (approved),
<snip>
> Here is the query:
> SELECT thread, modifystamp, count(id) AS tcount, abstime(modifystamp) AS
> latest, max(id) as maxid FROM tjavendan WHERE approved='Y' GROUP BY
> thread, modifystamp ORDER BY modifystamp desc, thread desc limit 40
Question. The field approved seems to have boolean values. If probability of
having either of value is 50%, I doubt planner will use index anyway.
Even assuming all possible values of a char variable, the choice isn't too
much, say if you have 1M row.
Correct me if I am wrong.
Bye
Shridhar
--
Either one of us, by himself, is expendable. Both of us are not. -- Kirk,
"The Devil in the Dark", stardate 3196.1
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: shridhar_daithankar@persistent.co.in
Subject: Re: any way to use indexscan to get last X values with "order by Y limit X" clause?
In-Reply-To: <3EECD0A2.8545.2FA1D9@localhost>
References: <5.2.1.1.0.20030615161722.025c7630@127.0.0.1> <3EECD0A2.8545.2FA1D9@localhost>
* 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