Performance tuning an Object-Relational Mapper (ORM)

25
Tuning an Object- Relational Mapper Key concepts and approaches

description

ORMs have become a standard tool, though they can shield us from thinking about what's really happening with our database. It is easy and common to inadvertently have the ORM inefficiently interact with the database, if you're not aware of how key concepts should be applied in different scenarios. Some of the most common performance problems in business applications today stem from misuse of the ORM. We'll go over key concepts to be aware of, that apply to the Entity Framework and Nhibernate, such as table mapping strategies and lazy/eager loading scenarios. We'll also cover simple profiling to get at the heart of ORM performance issues on a .NET project.

Transcript of Performance tuning an Object-Relational Mapper (ORM)

Page 1: Performance tuning an Object-Relational Mapper (ORM)

Performance Tuning an Object-Relational MapperKey concepts and approaches

Page 2: Performance tuning an Object-Relational Mapper (ORM)

ORMs are useful

Page 3: Performance tuning an Object-Relational Mapper (ORM)

Your messy code

Page 4: Performance tuning an Object-Relational Mapper (ORM)

My slick ORM

Page 5: Performance tuning an Object-Relational Mapper (ORM)
Page 6: Performance tuning an Object-Relational Mapper (ORM)
Page 7: Performance tuning an Object-Relational Mapper (ORM)

It’s not that easy

Page 8: Performance tuning an Object-Relational Mapper (ORM)

IMPACT

Page 9: Performance tuning an Object-Relational Mapper (ORM)

#ORMHate

Page 10: Performance tuning an Object-Relational Mapper (ORM)

Why care about how they work?

Page 11: Performance tuning an Object-Relational Mapper (ORM)
Page 12: Performance tuning an Object-Relational Mapper (ORM)

Why care about performance issues?

Page 13: Performance tuning an Object-Relational Mapper (ORM)
Page 14: Performance tuning an Object-Relational Mapper (ORM)

The main performance concerns

Page 15: Performance tuning an Object-Relational Mapper (ORM)

Too little Lazy. Too lazy.

Page 16: Performance tuning an Object-Relational Mapper (ORM)

Too long Elapsed time.

Page 17: Performance tuning an Object-Relational Mapper (ORM)

Too much Eager. Too eager.

Page 18: Performance tuning an Object-Relational Mapper (ORM)

Situations Grids

Page 19: Performance tuning an Object-Relational Mapper (ORM)

1. Profile Common Scenarios

Page 20: Performance tuning an Object-Relational Mapper (ORM)

Tools Profilers

Tracing (i.e. EFTracingProvider)

LinqPad

Log

Page 21: Performance tuning an Object-Relational Mapper (ORM)

Free Profilers Down to business

Page 22: Performance tuning an Object-Relational Mapper (ORM)

Premium Profilers See ORM contexts

Code that generates SQL easier to see

Bells & whistles (query plans, rows,

Page 23: Performance tuning an Object-Relational Mapper (ORM)

2. Optimize queries

Page 24: Performance tuning an Object-Relational Mapper (ORM)

3. Eager/lazy settings

Page 25: Performance tuning an Object-Relational Mapper (ORM)

4. And more