Posts

Showing posts from August, 2023

SQL Query Performance : No Join Predicate in Estimated Query Plan

Image
  What is the issue ? Found in one of the projects that a "view"  while querying took so much time. It was taking hours and hours when  SELECT field1, field2 FROM view  vs. getting executed within few seconds when  SELECT * FROM view. Example: SELECT field1, field2 FROM view1  => Takes hours to execute SELECT * FROM view1  => Executes within a minute  Little Background:  It was really surprising that view select was taking huge time when field names were specified in the select query. On the contrary when "*" was specified , it was taking very less time. It is usually believed and practiced to always use field names in select statements.  The view was huge , it was selecting records from around 7 tables and one more view. The view was joined with table1 with INNER join  Many of the tables were joined "LEFT OUTER JOIN" This view was returning around 15 fields and over 1 million records We could not replace this view with some stored procedure as this