SQL/MP Query Guide
Analyzing Query Performance
HP NonStop SQL/MP Query Guide—524488-003
6-6
Simple Query With ORDER BY Example
Simple Query With ORDER BY Example
Example 6-3 selects specific columns and orders them by salary:
Notice that the estimated cost of the simple query in Example 6-1 on page 6-4 is 2, and
that of the simple query with ORDER BY in Example 6-3 on page 6-6 is 3. This is
because the query in Example 6-3 on page 6-6 requires a sort operation for the
ORDER BY SALARY request.
Example 6-3. Simple Query With ORDER BY
>>PREPARE Q2 FROM
+> SELECT LAST_NAME, FIRST_NAME, SALARY
+> FROM EMPLOYEE
+> ORDER BY SALARY ;
--- SQL command prepared.
>>
>>EXECUTE Q2 ;
LAST_NAME FIRST_NAME SALARY
-------------------- --------------- -----------
DAY KATHRYN 12000.00
CHAPMAN SUSAN 17000.00
. . .
GREEN ROGER 175500.00
--- 57 row(s) selected.
>>
>>DISPLAY STATISTICS ;
Example 6-4. DISPLAY STATISTICS for Simple Query With ORDER BY
Estimated Cost 3
Start Time 95/09/11 09:06:11.863448
End Time 95/09/11 09:06:12.175160
Elapsed Time 00:00:00.311712
SQL Execution Time 00:00:00.124730
Records Records Disk Message Message Lock
Table Name Accessed Used Reads Count Bytes
\SQL1.$DATA8.PERSNL.EMPLOYEE
57 57 0 4 2962










