I have a table with total 198695 records and 96579 records with project_id =555. I have list interval partitioned the table by project_id. If i run the below query(without distinct),it takes 0.75 secs to run.
SELECT KW,SEARCH_VOLUME,TARGET_URL,KEYWORD_TYPE,RANK_DATE,RANK,URL,DOMAIN
from alps_project_theme_kw_v where min_rank =1 and project_id = 555;
while if i add distinct and run the below query, it takes 15 secs to run
SELECT distinct KW,SEARCH_VOLUME,TARGET_URL,KEYWORD_TYPE,RANK_DATE,RANK,URL,DOMAIN
from alps_project_theme_kw_v where min_rank =1 and project_id = 555;
For now the results fetched by both distinct and non distinct query is same (1636 rows) Can anyone please suggest how should i further tune the query? Please note:- i have only partitioned the table on project_id as mentioned above and analyzed it ,have not created any indexes.