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.

devx-admin

Share the Post: