jeudi 23 novembre 2017

DAO Pattern: Optimizing SQL statements

From what I understand the DAO pattern consists of

  • DAOs, that talk to the database and provide simple CRUD access
  • Services, that use the DAO to implement everything the clients need
  • Clients

But wouldn't this pattern get rid of all the little optimizations a database has to offer?

For example if I want to bulk insert 100.000 entries I could use one huge statement and let MySQL do its magic, but in the DAO pattern I am supposed to do this in the service and use the DAO, so I will send 100.000 INSERT-statements to MySQL. Or for complex Joins I will have to use something like LINQ instead of the probably better suited SQL.

For joins i have created some views now, but this also doesn't seem 100% right. What would be the correct way for this? Implement it in the DAO? Using Extension Methods maybe? Or just have more trust in C# and my hardware?

Please note that I use ADO.NET, not ORM.

Aucun commentaire:

Enregistrer un commentaire