Applies to: every Clarion version with a SQL driver; asked for PostgreSQL in 2017, the answers name MSSQL too.
Problem
A shop converting TPS files to PostgreSQL recreated every TPS key as a PostgreSQL index because they believed the compiled SET/NEXT code needed them, and asked whether going all-PROP:SQL would remove that need.
Solution
- A KEY in the dictionary of a SQL table is used by the driver only to build the ORDER BY clause of the SELECT it generates (ascending/descending per component). It does not have to exist on the server. Twenty keys in the FILE and none in PostgreSQL is fine; the poster's earlier errors were his own mistake.
- Which server index gets used is the server's decision, based on row counts and distribution; a query that returns a large share of the table is often a full scan on purpose. Create server indexes for the sorts and filters you actually run, not one per Clarion key.
- Do not rely on
SET(Key,Key)to limit rows on SQL: the result set is undefined and can be the whole table. The browse template does the same. Filter first:MyFile{PROP:WHERE} = '<your SQL WHERE text>'thenSET(MyF:SomeKey)and the LOOP. - A case-insensitive key in Clarion becomes
ORDER BY UPPER(column); an index on the plain column cannot serve it. The poster used thecitexttype for those columns and reported it working. - With PROP:SQL or PROP:SQLRowSet the statement is entirely yours; Clarion keys play no part, and you add the ORDER BY yourself over any columns. Going all-PROP:SQL is not necessary; the driver's generated SQL is good, and hand-built WHERE strings get messy.
- Look at BUFFER to fetch several rows per round trip; the template does not do that by default.
Caveats
- Optimizer hints exist on Oracle, not on PostgreSQL; the thread's view was that the server knows best.
- The shop in question used no templates; the SET(Key,Key) warning applies to template browses as well.
Today (2026)
Unchanged: dictionary keys still drive ORDER BY only, server indexes are a server-side design, and PROP:WHERE before SET remains the way to bound a loop. Not re-tested for this entry.
Sources: Jim W. (Apr 2017, the question), Sean H., Arnor B., Jon W. (Apr 2017) in softvelocity.clarion.databasedrivers.