From: | Peter Geoghegan <pg(at)bowt(dot)ie> |
---|---|
To: | james(at)emerton(dot)info |
Cc: | pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: BUG #14562: Query optimization when sorting multiple UNIQUE columns |
Date: | 2017-02-21 20:43:00 |
Message-ID: | CAH2-WzkzW3V=6EB3pA3+ahZSrz_+RnwYtSyOvXLKCFe17xpayw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
This is not a bug -- please don't post feature requests to pgsql-bugs.
pgsql-general would be better.
On Tue, Feb 21, 2017 at 11:58 AM, <james(at)emerton(dot)info> wrote:
> postgres=# EXPLAIN SELECT * FROM test ORDER BY key, id;
> QUERY PLAN
> ---------------------------------------------------------------
> Sort (cost=66.83..69.33 rows=1000 width=20)
> Sort Key: key, id
> -> Seq Scan on test (cost=0.00..17.00 rows=1000 width=20)
> (3 rows)
>
> postgres=# EXPLAIN SELECT * FROM test ORDER BY key;
> QUERY PLAN
> ------------------------------------------------------------------------------
> Index Scan using test_key_key on test (cost=0.28..49.27 rows=1000
> width=20)
> (1 row)
>
>
> It seems that these two queries are effectively identical, but the query
> planner makes significantly different choices. In our application there are
> several additional tables joined and the multiple column sort version is
> over two orders of magnitude slower.
What happens when the "key" column here has NULL values?
--
Peter Geoghegan
From | Date | Subject | |
---|---|---|---|
Next Message | Jim Nasby | 2017-02-22 00:02:01 | Bug in plpgsql with ON CONFLICT |
Previous Message | james | 2017-02-21 19:58:29 | BUG #14562: Query optimization when sorting multiple UNIQUE columns |