Speed Up SQL Queries

When dealing with large amount of data, speed is essential. The following link provides some good tips. However, the 23 tips are not very concretely related to my daily workflow, so I summarized the below:

  1. Query the large table all at once and once, when querying it, restrict in where clause to make it terse and hence fast.
  2. use CASE instead of UPDATE
  3. Try to use temp tables to improve cursor performance
  4. Avoid nest views
  5. Don’t use joins (denormalize your data) , use indexes, we should use index properly
  6.  Create joins with INNER JOIN (not WHERE)
  7. Use WHERE instead of HAVING to define filters
  8. Use Top or LIMIT 10 in the end to sample queries

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.