0% found this document useful (0 votes)
429 views3 pages

Performance Optimization Cheat Sheet

The document provides optimization tips across the database, application, and client tiers. Some key recommendations include ensuring database tables have primary keys and indexes, using caching at the application tier to avoid costly queries, and bundling JavaScript and CSS files along with other client-side optimizations like image compression. Premature optimization should be avoided, and optimizations should have observable performance improvements.

Uploaded by

Bittu Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
429 views3 pages

Performance Optimization Cheat Sheet

The document provides optimization tips across the database, application, and client tiers. Some key recommendations include ensuring database tables have primary keys and indexes, using caching at the application tier to avoid costly queries, and bundling JavaScript and CSS files along with other client-side optimizations like image compression. Premature optimization should be avoided, and optimizations should have observable performance improvements.

Uploaded by

Bittu Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Performance Optimization By: Mosh Hamedani

Rules of thumb
• Do not sacrifice the maintainability of your code to premature optimization.
• Be realistic and think like an “engineer”.
• Be pragmatic and ensure your efforts have observable results and give value. 


And remember: premature optimization is the root of all evils.

Database tier

Schema 

• Every table must have a primary key.
• Tables should have relationships.
• Put indexes on columns where you filter records on. But remember: too many
indexes can have an adverse impact on the performance.

• Avoid Entity-Attribute-Value (EAV) pattern.

Queries

• Keep an eye on EF queries using Glimpse. If a query is slow, use a stored
procedure.

• Use Execution Plan in SQL Server to find performance bottlenecks in your


queries.

If after all your optimizations, you still have slow queries, consider creating a
denormalised “read” database for your queries. But remember, this comes with the cost
of maintaining two databases in sync. A simpler approach is to use caching.

1
Performance Optimization By: Mosh Hamedani

Application tier
• On pages where you have costly queries on data that doesn’t change frequently,
use OutputCache to cache the rendered HTML.

• You can also store the results of the query in cache (using MemoryCache), but
use this approach only in actions that are used for displaying data, not modifying
it.

• Async does not improve performance. It improves scalability given that you’re
not using a single instance of SQL Server on the back-end. You should be using
a SQL cluster, or a NoSQL database (eg MongoDB, RavenDB, etc) or SQL
Azure.

• Disable session in web.config.

• Use release builds in production.

2
Performance Optimization By: Mosh Hamedani

Client Tier
• Put JS and CSS files in bundles.

• Put the script bundles near the end of the <body> element. Modernizr is an
exception. It needs to be in the head.

• Return small, lightweight DTOs from your APIs.

• Render HTML markup on the client. That’s the case with single page
applications (SPA).

• Compress images.

• Use image sprites. This is beyond the scope of the course and you need to read
about them yourself.

• Reduce the data you store in cookies because they’re sent back and forth with
every request.

• Use content delivery networks (CDN). Again, beyond the scope of the course.
Implementations vary depending on where you host your application.

You might also like