Quote:
Originally Posted by dineshdb
..Is Sybase doing something while trying to optimize the query for performance?
|
Sybase will look at what you've provided then decide if your criteria restrict the search to approx 10-20% of the table and, if not, it will table scan. In this particulr case your doing an operation on the field ( field + "%" ) so it will most likely give up guessing and just do a table scan anyway.
I think you'd do best adding a new field to the table to contain the smaller security_id field and doing an exact match on these fields. It would also be better naming your fields so you don't have two fields called security_id - one that contains the whole field and one that's just a part of the field. If you're only pulling data on one security id then you could add the "%" to the field in your program.
If this doesn't work then I think you should provide the create table and index statements for the tables involved and also give us an idea of what the data security_id field looks like.