pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Mitch Vincent <mitch@venux.net>
Cc: pgsql-sql@postgresql.org
Subject: Re: Timestamp indexes
Date: Fri, 21 Jul 2000 13:26:09 -0400
Message-ID: <13585.964200369@sss.pgh.pa.us> (raw)
In-Reply-To: <007701bff32b$ce21d410$4100000a@doot>
References: <001d01bff323$39cdb250$4100000a@doot>
	<13354.964192504@sss.pgh.pa.us>
	<007701bff32b$ce21d410$4100000a@doot>

"Mitch Vincent" <mitch@venux.net> writes:
> select * from applicants as a where (a.created::date > '05-01-2000' or
> a.resubmitted::date > '05-01-2000') order by (case when a.resubmitted >
> a.created then a.resubmitted else a.created end) desc limit 10 offset 0

> There is one of the queries.. I just remembered that the order by was added
> since last time I checked it's PLAN (in the 6.5.X days) -- could that be the
> problem?

Probably.  With the ORDER BY in there, the LIMIT no longer applies
directly to the scan (since a separate sort step is going to be
necessary).  Now it's looking at a lot more data to be fetched by
the scan, not just 10 records, so the indexscan becomes less attractive.

Might be interesting to compare the estimated and actual runtimes
between this query and what you get with "set enable_seqscan to off;"

			regards, tom lane



view thread (6+ messages)  latest in thread

Message-ID: <13585.964200369@sss.pgh.pa.us>
Permalink:  ../13585.964200369@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/13585.964200369@sss.pgh.pa.us

 · 

reply

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-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, mitch@venux.net
  Subject: Re: Timestamp indexes
  In-Reply-To: <13585.964200369@sss.pgh.pa.us>
  References: <001d01bff323$39cdb250$4100000a@doot> <13354.964192504@sss.pgh.pa.us> <007701bff32b$ce21d410$4100000a@doot> <13585.964200369@sss.pgh.pa.us>

* 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