Welcome to the SRP Forum! Please refer to the SRP Forum FAQ post if you have any questions regarding how the forum works.
Slow Index
Any idea as to why an index might be slow? I have a table with about 120,000 records in it and whenever I trying running a query against an indexed column its taking a long time. I've tried removing and readding the BTree index but the issue persists. Another issue I noticed that might be related is that whenever I try using Database_Services("Search_Index") against the same column, it's returning a different set of values when running the same command through TCL. The TCL results were correct compared with the Database_Services results (and yes I enabled the update index parameter) however the query takes much longer.
Comments
SELECT TABLE_NAME WITH STATUS EQ 'NEW'
and TABLE_NAME is the actual name of the table?
PLUS:
Database_Services("Search_Index") - I assume this is a typo as the service name is SearchIndex
P.S. While not necessarily a problem, I recommend putting a comparison operator in your statement. I tend to not like implicit behavior since it is not always known to everyone reading your code. Also, AREV supported more implicit syntax than OI, so that could created compatibility problems.
Just to clarify, I assume you were using SearchIndex and not "Search_Index". It's possible you have something custom named "Search_Index" in Database_Services but I'm assuming not.
The SearchIndex method uses btree.extract to query the indexes directly. When you do the TCL command, it may or may not use the indexes like btree.extract does.
Are you checking Error_Services after making the call to SearchIndex, if not, are any errors reported?
Is your search value a string or numerical value like 1234 or 0001234?
If needed, is it possible for you to remove all the indexes from the table and ensure the '!TABLENAME' table (where 'TABLENAME' is the name of your table with the index) is removed from the system prior to adding the index back onto the table?
I ended up finding an article within the SRP Wiki regarding removing indexes manually and that fixed the problem. After removing all indexes, I ended up deleting the the two dictionary files "%PROTECT.SPEC%" and "%FIELDS%" and then removed the index table "!DATANAV". I restarted OI and added the BTREE index to the field I was having issues with and now the index seems to be working like a charm in the TCL and using Database_Services("SearchIndex").
The only remaining issue I'm trying to tackle is that when running the code:
Thank you guys for the help, the wiki link I was referring to is below.
https://wiki.srpcs.com/display/ProgrammingTechniques/Removing+Indexes+Manually
I forgot about that. Ended up running that on the system with the issue and now its working. Thanks a million!