devxlogo

Fetch Only Required Columns From a Database to Improve Performance

Fetch Only Required Columns From a Database to Improve Performance

The call ‘select * from ‘ becomes costly when tables have a lot of fields. Because every data field would be required to be sent across the network (or processed) and buffered, reducing the number of data fields fetched directly enhances query and application performance. Therefore, you should fetch only required columns from your database and avoid queries like ‘select * from ‘. The queries that check for the existence of a record and use ‘select * from ‘ should be modified by putting * into single quotes. For example, it is better to fire a query like

      select '*' from  where  = 

in place of

      select * from  where  = 

to check for the existence of a record.

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist