Timeline for How do I approach structuring when to read/write objects to db?
Current License: CC BY-SA 4.0
18 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jul 17, 2018 at 22:10 | review | Close votes | |||
| Aug 1, 2018 at 3:05 | |||||
| Jul 17, 2018 at 21:29 | answer | added | Lewis Pringle | timeline score: 1 | |
| Jul 17, 2018 at 21:03 | answer | added | John | timeline score: 0 | |
| Jul 17, 2018 at 20:33 | comment | added | Robert Harvey | What I expect you to do is think and come up with the most sensible solution for each particular situation. That's what you're paid to do as a software developer. No solution ever works one hundred percent of the time. | |
| Jul 17, 2018 at 20:26 | comment | added | Robert Harvey | You don't need stored procedures. You just need an ORM that supports SQL statements, as most of them do. | |
| Jul 17, 2018 at 20:23 | comment | added | Drathier | It could be too expensive to run on the sql server, and some things are not expressible in sql. Do you expect me to write servers as stored procedures in sql? Is that your solution? :) | |
| Jul 17, 2018 at 20:08 | comment | added | Robert Harvey | Whatever calculation you come up with, it's almost certainly expressible as a SQL statement. | |
| Jul 17, 2018 at 20:03 | comment | added | Drathier | Well, what if it's not simple enough? Let's say we need some complex/expensive computation before we write to all user objects. Give me the benefit of the doubt :) | |
| Jul 17, 2018 at 19:31 | comment | added | Robert Harvey | In the example you just gave, you can almost certainly accomplish that kind of update with a single SQL statement. If it's an unconditional update, you don't even need a read-before-write. | |
| Jul 17, 2018 at 19:28 | comment | added | Drathier | What if you have multiple ways to fetch this object? E.g. by username, or as a member of a group. You want to modify some field on all users the first user is a member of, so you fetch a user, lookup their groups, and fetch all members of (one of) those groups, and fetch those user objects. Now you have two+ copies of a single user object. | |
| Jul 17, 2018 at 19:19 | comment | added | Robert Harvey | Why would you do that? Read/write the entire object. | |
| Jul 17, 2018 at 19:16 | comment | added | Drathier | Read before write is ok. Firing off a sql update every time I set a field of an object in python is not. | |
| Jul 17, 2018 at 18:50 | answer | added | Armando Garza | timeline score: 4 | |
| Jul 17, 2018 at 18:29 | comment | added | Robert Harvey | Read before write is a common practice in line of business applications. Are you sure it causes an intractable performance problem? The only way to know for sure is to measure. We would need to know more about your specific scenario to offer actionable advice. | |
| Jul 17, 2018 at 18:26 | comment | added | Drathier | @RobertHarvey e.g. fetching the user object twice to serve the same request, it might have changed between fetches. Or we might want to update one of them, and somehow (magically?) the other copy should also be updated, or at least we should detect that we've accidentally fetched two copies. | |
| Jul 17, 2018 at 17:22 | answer | added | Oleksi | timeline score: 0 | |
| Jul 17, 2018 at 17:21 | comment | added | Robert Harvey | Can you describe one of your race conditions a bit more specifically? | |
| Jul 17, 2018 at 17:16 | history | asked | Drathier | CC BY-SA 4.0 |