Ralf Koellner wrote:

> I'd like to know, if it's possible to use an "ORDER BY"-sorting 
> case-insensitive with sap-db.


There are functions like UPPER/LOWER available, which have to be used. 
There is no other chance to say 'case-insensitive'


> For example:
> 
> table COMPANYNAMES:
> ENTRY | COMPANY
> 1   |   IBM
> 2   |   bea
> 
> "SELECT COMPANY FROM COMPANYNAMES ORDER BY COMPANY" does 
> sort, but you 
> first get all company names beginning with a upper case, then 
> the ones 
> beginning with a lower case.
> 
> "SELECT COMPANY FROM COMPANYNAMES ORDER BY UPPER(COMPANY)" does work, 
> but not so fast.


Ok, you used the correct function. And if you find a time difference, see
the following description:
company is your first primary key column or an indexed column.
If you do NOT use UPPER, then there are 2 possiblilities:
1. company is the first keycolumn, no reordering of rows has to be done,
every time, the user
fetches the next row, the next row out of the primary B*-tree can be
returned, no physical building
of a resultset is needed.
2. company is an indexed column. Because no other column is used which is
not in the index
the index is scanned during fetch, no physical building of a resultset is
needed.

If you DO use UPPER, no stored sequence can be used. The whole resultset has
to be
prepared, physically stored and sorted. And before your first fetch has a
chance to get the
first resultrow, the whole work has to be done. That lasts much longer than
in the other case.

If your column was neither primary key column nor indexed, then no time
difference of
remarkable amount should be there. It is only there because of your special
column.

Elke
SAP Labs Berlin
_______________________________________________
sapdb.general mailing list
[EMAIL PROTECTED]
http://listserv.sap.com/mailman/listinfo/sapdb.general

Reply via email to