从 table 获取唯一记录且对性能影响较小的最佳方法是什么?

What is the best way to get the unique records from a table with less impact on performance?

从 table 获取唯一记录且对性能影响较小的最佳方法是什么?这些是导致重复问题的列组合集。

SELECT
  PAY_RANGE_START_DATE_KEY,
  AA_PERSON_NATURAL_KEY,
  AA_PERSON_ASSIGNMENT_KEY,
  SCHEDULE_LINE_ID,
  SRC_CREATED_DATE,
  SRC_LAST_UPDATE_DATE
FROM
  EDWFIN.PSP_LABOR_SCHD_DAY_F_ROLLUP_FRS_356
GROUP BY
  PAY_RANGE_START_DATE_KEY,
  AA_PERSON_NATURAL_KEY,
  AA_PERSON_ASSIGNMENT_KEY,
  SCHEDULE_LINE_ID,
  SRC_CREATED_DATE,
  SRC_LAST_UPDATE_DATE

您必须检查哪个查询性能更高,但您也可以使用:

SELECT PAY_RANGE_START_DATE_KEY,
       AA_PERSON_NATURAL_KEY,
       AA_PERSON_ASSIGNMENT_KEY,
       SCHEDULE_LINE_ID,
       SRC_CREATED_DATE,
       SRC_LAST_UPDATE_DATE
FROM   (
  SELECT PAY_RANGE_START_DATE_KEY,
         AA_PERSON_NATURAL_KEY,
         AA_PERSON_ASSIGNMENT_KEY,
         SCHEDULE_LINE_ID,
         SRC_CREATED_DATE,
         SRC_LAST_UPDATE_DATE,
         ROW_NUMBER() OVER (
           PARTITION BY PAY_RANGE_START_DATE_KEY,
                        AA_PERSON_NATURAL_KEY,
                        AA_PERSON_ASSIGNMENT_KEY,
                        SCHEDULE_LINE_ID,
                        SRC_CREATED_DATE,
                        SRC_LAST_UPDATE_DATE
           ORDER BY ROWNUM
        ) AS rn
  FROM  EDWFIN.PSP_LABOR_SCHD_DAY_F_ROLLUP_FRS_356
)
WHERE  rn = 1