Advanced SQL Queries

I was looking into the course of advanced sql server, where I found 1 question


1] A developer should favor using a Structure instead of the Entity in the output of a SELECT SQL Query. Do you agree with this statement?

and answer of this question is 

Yes, because queries will retrieve fewer Attributes and less data. It looks weird for me specially "and less data" 

Can someone please confirm, How it is correct?

Hi Pradip,

your answer is correct. 

If you reduce the amount of fields only to those you need, you improve query performance and you improve transporting a smaller data structure between calls. Although many times the performance gain is irrelevant.

Regards

To add a little to José's answer, an aggregate is optimized by the plaform and (data in) fields that are not used in your flow won't be fetched from the database. Advanced queries aren't optimized by the platform Therefore it's good to only include the fields that you need and thus use a structure as the output instead of the full entity.

Also, when using the full entity, it may lead to errors when a field is added to the entity and the query isn't adjusted accordingly.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.