Why is ORM considered good but “select *” considered bad?

后端 未结 12 1797
误落风尘
误落风尘 2021-01-29 23:25

Doesn\'t an ORM usually involve doing something like a select *?

If I have a table, MyThing, with column A, B, C, D, etc, then there typically would be an object, MyThin

12条回答
  •  我在风中等你
    2021-01-30 00:10

    Even ORMs need to avoid SELECT * to be effective, by using lazy loading etc.

    And yes, SELECT * is generally a bad idea if you aren't consuming all the data.

    So, do you have different kinds of MyThing objects, one for each column combo? – Corey Trager (Nov 15 at 0:37)

    No, I have read-only digest objects (which only contain important information) for things like lookups and massive collections and convert these to fully hydrated objects on demand. – Cade Roux (Nov 15 at 1:22)

提交回复
热议问题