January 21st, 2013, 04:23 PM
Performance of a SQL query
I am trying to gather distinct values from a view in conjiuction with a join to another table of disntinct values by excluding some values.
select distinct id
where id NOT IN(select distinct id
where is_browse = TRUE)
and layer != 'acca'
and layer != 'base';
The view has about 120 k records and the table has 1.6 million rows and the query never finishes and has been running for hours.
Is there a better way to write this up. Any help is much appreciated.
January 21st, 2013, 05:41 PM
I will not read nor answer questions where the SQL code is messy and not formatted properly using [code] tags.
Tips on how to ask better questions:
January 26th, 2013, 05:22 PM
DO NOT USE with Large data
It is always a bad idea to use IN statements with large data.
Write a Sub Query.
It is better write a SQL and them use the SELF JOIN.
I wish this will help you!