AW: Re: Slow Performance in PostgreSQL - Mailing list pgsql-hackers

From Zeugswetter Andreas SB
Subject AW: Re: Slow Performance in PostgreSQL
Date
Msg-id 11C1E6749A55D411A9670001FA6879633683A1@sdexcsrv1.f000.d0188.sd.spardat.at
Whole thread Raw
List pgsql-hackers
> > There is one table, let's
> > say table1, with about 11.0000 rows. On doing a "select distinct var1
> > from table1" via ODBC-Driver, I had to wait about 15 sec for the result.

1. I assume following index exists: create index table1_x0 on table1 (var1);

"select distinct" when executed through a btree index could benefit from
an optimization as follows:

for each "key" that is already in a sorted list output skip the heap tuple
lookup, since for a duplicate it is not necessary to know the tx status,
not sure if that is implementable though.

(PostreSQL needs to look up the tx status in the table for each key in index)

The performance difference is unfortunately to be expected, since Centura can
probably do the distinct by only looking at the index.

You could try to normalize your schema (pull those values out into an extra table) 
if you need such "distinct" queries to be fast.

Andreas


pgsql-hackers by date:

Previous
From: "Christopher Kings-Lynne"
Date:
Subject: Bug in ADD COLUMN with REFERENCES
Next
From: Zudi Iswanto
Date:
Subject: ...