AW: [HACKERS] TODO list updated

From: Zeugswetter Andreas SB <ZeugswetterA(at)wien(dot)spardat(dot)at>
To: "'Bruce Momjian'" <pgman(at)candle(dot)pha(dot)pa(dot)us>, "'Tom Lane'" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "'Hiroshi Inoue'" <Inoue(at)tpf(dot)co(dot)jp>, "'PostgreSQL-development'" <pgsql-hackers(at)postgreSQL(dot)org>
Subject: AW: [HACKERS] TODO list updated
Date: 2000-01-13 10:38:10
Message-ID: 219F68D65015D011A8E000006F8590C603FDC203@sdexcsrv1.f000.d0188.sd.spardat.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


> > Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> > > We currently do not use indexes to handle ORDER BY
> because it is slower,
> >
> > Er, actually, we *do* use indexes for ORDER BY currently:
> >
> > regression=# explain select * from tenk1 order by unique1;
> > NOTICE: QUERY PLAN:
> > Index Scan using tenk1_unique1 on tenk1 (cost=760.00
> rows=10000 width=148)
> >
> > If you start psql with PGOPTIONS="-fi" you can see that the
> optimizer
> > believes an explicit sort would be much slower:
> >
> > regression=# explain select * from tenk1 order by unique1;
> > NOTICE: QUERY PLAN:
> > Sort (cost=3233.91 rows=10000 width=148)
> > -> Seq Scan on tenk1 (cost=563.00 rows=10000 width=148)
> >
> > but (at least on my machine) the explicit sort is marginally faster.
> > Evidently, the cost estimate for an explicit sort is *way* too high.

Doing the sort, or the index access is allways a tradeoff.
For interactive access the index is faster,
for batch mode the sort is faster.

I would try to avoid a sort, that would need more than a few
100 Mb of sort disk space, even if I would eventually get my last
row faster.
The tradeoff is, that you wait an hour before you get the first row,
and block all those resources until you finish.

The index access gives the first rows fast, and does not block
resources.

In mathematical terms I would give the sort an exponential cost
curve regarding sort size
(probably also dependent on ~16 * available sort memory),
and the index access a linear cost curve.

Andreas

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2000-01-13 11:00:28 Re: [HACKERS] libpq+MB/putenv(), getenv() clean up
Previous Message Karel Zak - Zakkr 2000-01-13 10:11:51 Re: [HACKERS] Status request for 7.0