SELECT DISTINCT: A SQL Case Study There is an understanding in the database world that using a 'SELECT DISTINCT' SQL query is not a good idea, because it is essentially getting duplicate rows out of the database and then discarding them. Usually it's better to rearrange the 'WHERE' clause in the query to only get the rows you need. Tom Copeland gives a step-by-step 'case study' of analyzing a query in PostgreSQL and how to ensure that your SQL rewrite is actually paying off. There is an understanding in the database world that using a 'SELECT DISTINCT' SQL query is not a good idea, because it is essentially getting duplicate rows out of the database and then discarding them. Usually it's better to rearrange the 'WHERE' clause in the query to only get the rows you need. Tom Copeland gives a step-by-step 'case study' of analyzing a query in PostgreSQL performancepostgresqlqueriessqltotalunix in programming > sqlwith databasedistinctprogrammingqueryselectsqlunderstandingworld