String or Cursor in Oracle PLSQL

Asked

Viewed 294 times

2

Good afternoon,

I have a precedent that executes a select, but work with a bit map, where I use conditionals to perform a specific select depending on the bit that is passed as parameter to Precedent. In this scenario I use a varchar variable to store the select instruction to be executed, however it may happen that more of the bit is on, so I perform a concatenation with the UNION operator to join another selects into one.

My question is the following, if you use a cursor to store the data instead of using concatenated strings, it could increase the performance of the process or bring the results faster than the current logic?

Thanks in advance.

  • 1

    You can post the code of the program?

1 answer

2


No. The cost of creating a cursor for the database is much higher than handling the strings

  • Can you tell if there is another way to optimize this scenario?

  • maybe using numerical values and treating it with bitwise logic operations (BITAND, BITOR) can speed up the process.

  • This already happens, see:

  • ah... now cleared. In the question it seemed that you used strings to create the bit map. The problem is that the cursor is specific to a stored Procedure, that is you will always have to recreate the cursors when starting SP. What happens to send the query again, or maybe it takes longer because of the cost of creating the cursor.

  • 1

    This you saw that concatenates the query and with the UNION operator will join the selects, if all the 7 bits I use is turned on it will go through the 7 ifs and joining the selects until making a single select. So I thought about the cursor, but now I think that in the end it may be more costly for the bank. Thanks for the help.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.