DISTINCT in a SELECT query list
This section describes how to optimize queries that have the DISTINCT keyword in their SELECT list.
This section describes how to optimize queries that have the DISTINCT
keyword in their SELECT
list. The techniques for optimizing DISTINCT queries are similar to the techniques for optimizing GROUP BY queries because when processing queries that use DISTINCT
, the Vertica optimizer rewrites the query as a GROUP BY
query.
The following sections below this page describe specific situations:
- Query has no aggregates in SELECT list
- COUNT (DISTINCT) and other DISTINCT aggregates
- Approximate count distinct functions
- Single DISTINCT aggregates
- Multiple DISTINCT aggregates
Examples in these sections use the following table:
=> CREATE TABLE table1 (
a INT,
b INT,
c INT
);