Which should I use for performance reasons?
The Database.Save methods retrieve the value of the primary key field using GetValue , then call Database.Insert or Database.Update accordingly.
Therefore, you should use Database.Save when your code really needs to save changes to an object that may be new or existed before. Also, note that for your table, you must use the auto-increment primary key column for Database.Save .
Even without a slight difference in performance, I would prefer the correct semantics - with Insert or Update over Save.
One of them is no less convenient for me than the other ...
This is not true.
Database.Insert(poco) will look up the values ββfor tableName and pkName in the user-defined attributes of the definition of your poco class. If you use T4 templates, these values ββwill be automatically synchronized with your database, and they will be specified only in one place. On the other hand, if you pass them in every method call, they will be repeated countless times in your code base. DRY. What if you need to change one of the values ββlater?
Now Database.Insert(poco) will be slightly less efficient due to this search. However, PetaPoco caches the result of this search in a static dictionary, so the performance impact will be very small after the first search:
RWLock.EnterReadLock(); PocoData pd; try { if (m_PocoDatas.TryGetValue(t, out pd)) return pd; } finally { RWLock.ExitReadLock(); }
source share