KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Avoiding SELECT * for better performance
PRODUCT: 4D | VERSION: 11.5 | PLATFORM: Mac & Win
Published On: February 5, 2010
Your current browser may not allow you to download the asset. We recommend Mozilla Firefox or Google Chrome.
Log In

The more data that is read, the slower a query will become. It is a good habit to always specify which columns you need when you are writing your SELECT statements.

Example 1: Not the preferred way to do it

ARRAY TEXT(UserName_aT;0)
BEGIN SQL
    SELECT *
    FROM user
    WHERE user_id = 1
    INTO :UserName_aT;
END SQL

$Msg_T:= "Welcome "+UserName_aT{1}


Example 2: A more effecient way to do it
C_TEXT(UserName_T)
BEGIN SQL
    SELECT userName
    FROM user
    WHERE user_id = 1
    INTO :UserName_T;
END SQL

$Msg_T:= "Welcome "+UserName_T


The performance difference is more significant with larger returned data sets.