How to restrict columns retrieved in Glide Query
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2016 12:56 AM
Hi All, we are all familiar with query using Glide Record. But when we query table for e.g. sys_user we can restrict the number of records retrieved by specifying addQuery conditions.
But this retrieves all the columns within the record. It impacts performance if there are many glide calls. Question is : is there a way to restrict number of columns retrieved in Glide Record.
Is there something I can do to say I only want a certain set of columns.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2016 01:10 AM
Unfortunately there is no supported method in restricting the columns to be returned from a GlideRecord.
A workaround would be to define a database view and only include the columns you need. However, these views are read only.
For more information on database views see here: Database views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2016 01:11 AM
I believe creating an index for the table would be one possibility to fetch only selected columns and reduce performance impact.
Lets see what others have to say for your question.
Thanks and Regards,
Aswin Siddalingam

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2016 01:14 AM
How do you think an Index would help? As per my experience an index helps to improve speed of searching, but the GlideRecord would still return all columns.
But essentially, if only the performance is an issue for Rohan, than yes, setting an index on the columns of the query condition would certainly help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2016 01:15 AM
Hi Rohan,
If you query a record it will give you the sys_id of whole record including both records (rows) and fields (columns).
You can try using gear box and limit the columns.
You can limit for records using setLimit() this method.