How to do reset columns from collection Query by magento 2?

You can reset columns from the given collection in Magento.

Many times you want to be sure of the better performance for a given query and you want to reset a specific collection by fetching a few of the columns in the result.

Magento Collection provides the reset() method to clear specific part from the sql query.

This will be helpful while working with some third-party extensions and if you found you can do a better performance for a given collection, you can do a reset method to fetch specific required fields on the output.

<?php
$collection = $this->getProductCollection();
$select = $collection->getSelect();
// reset columns
$select->reset(\Zend_Db_Select::COLUMNS);
$select->columns(['e.sku', 'e.entity_id']);

Using the above PHP code, Reset Columns with you can fetch only SKU and entity_id as result.

You can check more database related query by open a link, Direct SQL Query in Magento 2