3 ms·
When writing a query with multiple joins and functions, the query plan will build a pipeline that pulls the data from storage if it does not already exist in th
by treebeard901 8y ago
When writing a query with multiple joins and functions, the query plan will build a pipeline that pulls the data from storage if it does not already exist in the cache.
Then it has to process the data based on the declarative statement that was sent to the query engine. This means it may need temporary spools in memory or on disk to handle sorting, hash joins, etc.
Sometimes the engine is able to optimize this pipeline and only pull in the columns used in the outermost part of the query.
Being explicit in your column selection can greatly reduce the amount of memory and CPU needed to generate the results.
Probably the worst impact this can have is when an application is using a query with SELECT * on the data side when only a handful are used in the application.
Outside of disk IO, memory usage and CPU usage, now you have incurred an overhead by sending data across the network that is never being used.