Hacker News new | past | comments | ask | show | jobs | submit login

He says: "Selecting all columns with the star () operator is expensive, and that's what LINQ to SQL always does by default."

Doing a select is expensive relative to what? Assuming your select * where clause has only the index key in it, then select any column in the leaf of the index has the same cost as selecting all columns in the leaf. The expense is the disk read, if necessary.

Also, If you select the entire object then linq does a select * because it has to populate every value of the object. If you only need an id column, just select the id column.

Then he says: "Now, retrieving 48 individual records one by one is sort of silly, becase you could easily construct a single where Id in (1,2,3..,47,48) query that would grab all 48 posts in one go. But even if we did it in this naive way, the total execution time is still a very reasonable (48 * 3 ms) + 260 ms = 404 ms."

He says he could do an IN list, but he never does it. He assumes that selecting on one id is the worst case and then multiplying it by 48 gives him a total. The true time would depend on whether the index pages were in the cache of the database. It also depends on whether the query being run uses parameter versus literals because now compiling/optimizing time is there too.

Specifically, what point are you referring to that is valid?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: