Welcome to the SRP Forum! Please refer to the SRP Forum FAQ post if you have any questions regarding how the forum works.

Database Services "SearchIndex" Function vs. RList Subroutine

I recently came across the Database_Services("SearchIndex") function and have started using it instead of simple RList routines that retrieves a list of records. For example, if I wanted to select a list of records that have a status of "ACTIVE" using an RList routine, I would do something along the lines of the statement below:
- RList("SELECT TABLE_NAME with STATUS 'ACTIVE'", 5)
- Then I would loop through the list returned and append each @ID to a list I'll call "activeRecords" for now.

After learning about Database_Services("SearchIndex"), I've replaced the entire RList and loop routine above to a one line statement below:
- activeRecords = Database_Services("SearchIndex", "TABLE_NAME", "STATUS", "ACTIVE", FALSE$)

My question is, are there any disadvantages to using Database_Services("SearchIndex") instead of RList in the example above? If not this would simplify a lot of my code. I've gotten accurate results from a couple tests I tried but don't want to go ahead and start replacing every instance of an RList routine for this project I'm working on until confirmed.

Comments

  • @Luann_Dias - No disadvantages based on your use case. The SearchIndex service is really a wrapper around the Btree.Extract routine, which is one of the fastest ways to search for indexed values. SearchIndex just does a bit of the leg work for you to make it easy. If you ever needed to search against multiple indexed columns in the same table, then you'll want to call Btree.Extract directly since SearchIndex is designed to only handle one indexed column search.
  • Excellent sounds good, Thank you!
  • Not to take anything away from SRP's great routines, but did you know you can do:

    RList("SELECT TABLE_NAME with STATUS 'ACTIVE'", 2,ActiveRecords)
  • @BarryStevens, I haven't tried that but I can see scenarios where I'd want to use that instead. I got too comfortable with option 5 and haven't tried others so thank you!
  • Interesting! Previous versions of the RList documentation would state:


    I wonder if RList always had that functionality but it wasn't exposed, especially in the 16bit days.
Sign In or Register to comment.