Re: [PERFORM] Unnecessary DISTINCT while primary key in SQL

2017-11-05 Thread David Rowley
On 5 November 2017 at 04:20, 刘瑞 wrote: > CREATE TABLE test_tbl ( k INT PRIMARY KEY, col text) > INSERT into test_tbl select generate_series(1,1000), 'test'; > > SQL with DISTINCT: > test=# explain analyze select distinct col, k from test_tbl order by k limit > 1000; >

[PERFORM] Unnecessary DISTINCT while primary key in SQL

2017-11-05 Thread 刘瑞
Hi all: I am new in pgsql, I am even new in using mailing list. I send this email just to give a suggestion on performance. I found that if primary key or a colume which has an unique index, is in a select sql,the distinct sometimes is Unnecessary. Actually, the SQL with DISTINCT will runs more