More efficient ways to deal with query than using IN clause???

There is a module in an application that I wrote that under certain circumstances executes a query that looks something like the following:
SELECT field1, field2
from table
where id in (1,2............1000)
OR id in (1001,1002.............2000)
OR id in (59000, 59001.................60000);
To clarify... Yes.. I am saying that because of oracle's limitation on 1000 expressions in an IN clause, there would be up to 60 different IN clauses.
When I initially wrote this module... I wasn't aware of the volume of data that I was dealing with. I fully expect that when running this module with real data, it is going to be painfully slow. I am also worried about out of memory errors. Does anyone have suggestions? Thanks!
Btw... This is using ORACLE 10g

Depending on the number of rows in the table, I would tend to look at loading the ID's into a temporary table and then using that temporary table in your search, i.e.
SELECT field1, field2
  FROM table
WHERE id IN (SELECT id FROM new_temp_table)or
SELECT field1, field2
  FROM table a
WHERE EXISTS (
    SELECT 1
      FROM new_temp_table b
     WHERE a.id = b.id )Of course, if the logic for figuring out the 60,000 ID's you want to search on can be expressed as a SQL query, you could replace the temp table in the above examples with that particular SQL expression.
Justin

Similar Messages

  • Creating a time channel in the data portal and filling it with data - Is there a more efficient way than this?

    I currently have a requirement to create a time channel in the data portal and subsequently fill it with data. I've shown below how I am currently doing it:
    Time_Ch = ChnAlloc("Time channel", 271214           , 1      ,           , "Time"         ,1                  ,1)              'Allocate time channel
    For intLoop = 1 to 271214
      ChD(intLoop,Time_Ch(0)) = CurrDateTimeReal          'Create time value
    Next
    I understand that the function to create and allocate memory for the time channel is extremely quick. However the time to store data in the channel afterwards is going to be highly dependent on the length I have assigned to the Time_Ch. In my application the length of Time_Ch is variable but could easily be in the order of 271214 or higher. Under such circumstances the time taken to fill Time_Ch is quite considerable. I am wondering whether this is the most appropriate way of doing things or whether there is a more efficient way of creating a time channel and filling it.
    Thanks very much for any help.
    Regards
    Matthew

    Hi Matthew,
    You are correct that there is a more efficient way to do this.  I'm a little confused about your "CurrDateTimeReal" assignment-- is this a constant?  Most people want a Time channel that counts up linearly in seconds or fractions of a second over the duration of the measurement.  But that looks like you would assign the same time value to all the rows of the new Time channel.
    If you want to create a "normal" Time channel that increases at a constant rate, you can use the ChnGenTime() function:
    ReturnValue = ChnGenTime(TimeChannel, GenTimeUnit, GenTimeXBeg, GenTimeXEnd, GenTimeStep, GenTimeMode, GenTimeNo)
    If you really do want a Time channel filled with all the same values, you can use the ChnLinGen() function and simply set the GenXBegin and GenXEnd parameters to be the same value:
    ReturnValue = ChnLinGen(TimeChannel, GenXBegin, GenXEnd, XNo, [GenXUnitPreset])
     In both cases you can use the Time channel you've already created (which as you say executes quickly) and point the output of these functions to that Time channel by using the Group/Channel syntax of the Time channel you created for the first TimeChannel parameter in either of the above functions.
    Brad Turpin
    DIAdem Product Support Engineer
    National Instruments

  • A more efficient way to assure that a string value contains only numbers?

    Hi ,
    I'm using Oracle 9.2.0.6.
    I was curious to know if there was any way I could write a more efficient query to determine if a string value contains only numbers.
    Here's my current query. This SQL is from a sub query in a Join clause.
    select distinct cta.CUSTOMER_TRX_ID, to_number(cta.SALES_ORDER) SALES_ORDER
                from ra_customer_trx_lines_all cta
                where length(cta.SALES_ORDER) = 6
                and cta.SALES_ORDER is not null
                and substr(cta.SALES_ORDER,1,1) in('1','2','3','4','5','6','7','8','9','0')
                and substr(cta.SALES_ORDER,2,1) in('1','2','3','4','5','6','7','8','9','0')
                and substr(cta.SALES_ORDER,3,1) in('1','2','3','4','5','6','7','8','9','0')
                and substr(cta.SALES_ORDER,4,1) in('1','2','3','4','5','6','7','8','9','0')
                and substr(cta.SALES_ORDER,5,1) in('1','2','3','4','5','6','7','8','9','0')
                and substr(cta.SALES_ORDER,6,1) in('1','2','3','4','5','6','7','8','9','0')This is a string where I'm finding A-Z-a-z characters and '/' and '-' characters in all 6 positions, plus there are values that are longer than 6 characters. That's what the length(cta.SALES_ORDER) = 6 is for. Also, of course. some cells are NULL.
    So the question is, is there a more efficient way to screen out only the values in this field that are 6 character numbers or is what I have the best I can do?
    Thanks,

    I appreciate all of your very helpfull workarounds. The cost is a little better in all cases than my original where clause.
    To address the discussion that's popped up about design from this question, I can say a few things that should clear , at least, my situation up.
    First of all this custom quoting , purchase order , and sales order entry system WAS written by a bunch a of 'bad' coders who didn't document their work and then left. We don't even have an ER diagram
    The whole project that I'm only a small part of is literally trying to put Humpty Dumpty together again and then move it from a bad custom solution into Oracle Applications.
    We're rebuilding, documenting, and doing ETL. This is one of your prototypical projects from hell.
    It's a huge database project so we're taking small bites as a time. Hopefully, somewhere right before Armageddon hits, this thing will be complete.
    But until then,..., well,..., you know the drill.
    Thanks Again.

  • XmlDataProvider .... is gone completely in my Xaml file. Why? How many different ways to deal with xml data source through WPF

    I followed a procedure described in a book.
    1. insert "Inventory.xml" file to a project "WpfXmlDataBinding" .
    2. add the XML data source through the data panel of "blend for 2013", named it "InventoryXmlDataStore" and store it in the current document.
    3. dragged and droppped the nodes from the Data panel onto the artboard.
    Then I checked my Xaml file against the one provided by the book
    Xaml file by the book:
    <Window.Resources>
    <!-- This part is missing in my xaml file --><XmlDataProvider x:Key="InventoryDataSource"
    Source="\Inventory.xml"
    d:IsDataSource="True"/>
    <!-- This part is missing in my xaml file -->
    <DataTemplate x:Key="ProductTemplate">
    <StackPanel>
    <TextBlock Text="{Binding XPath=@ProductID}"/>
    <TextBlock Text="{Binding XPath=Cost}"/>
    <TextBlock Text="{Binding XPath=Description}"/>
    <CheckBox IsChecked="{Binding XPath=HotItem}"/>
    <TextBlock Text="{Binding XPath=Name}"/>
    </StackPanel>
    </DataTemplate>
    </Window.Resources>
    <Grid>
    <ListBox HorizontalAlignment="Left"
    ItemTemplate="{DynamicResource ProductTemplate}"
    ItemsSource="{Binding XPath=/Inventory/Product}"
    Margin="89,65,0,77" Width="200"/>
    </Grid>
    my Xaml file:
    <Window x:Class="WpfXmlDataBinding.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="922" Width="874">
    <Window.Resources>
    <DataTemplate x:Key="ProductTemplate">
    <StackPanel>
    <TextBlock Text="{Binding XPath=@ProductID}"/>
    <TextBlock Text="{Binding XPath=Cost}"/>
    <TextBlock Text="{Binding XPath=Description}"/>
    <CheckBox IsChecked="{Binding XPath=HotItem}"/>
    <TextBlock Text="{Binding XPath=Name}"/>
    </StackPanel>
    </DataTemplate>
    </Window.Resources>
    <Grid DataContext="{Binding Source={StaticResource InventoryXmlDataStore}}">
    <ListBox HorizontalAlignment="Left" Height="370"
    ItemTemplate="{DynamicResource ProductTemplate}"
    ItemsSource="{Binding XPath=/Inventory/Product}"
    Margin="65,55,0,0" VerticalAlignment="Top" Width="270"/>     
        </Grid>
    </Window>
    All looks quite the same except the <XmlDataProvider ....> part under <Window.Resources>, which is gone completely in my Xaml file.
    1, Why?
    2, How many different ways to deal with xml data source through WPF?
    Thanks, guys.
    (ps My "WpfXmlDataBinding" runs without problem through.)

    Never do yourself down Richard.
    Leave that to other people.
    It's quite common for smart developers to think they're not as good as they are.
    I coach a fair bit and it's a surprisingly common feeling.
    And to repeat.
    Never use anything ends .. provider.  They're for trivial demo apps.  Transform xml into objects and use them.  Write it back as xml.  Preferably, use a database.
    You want to read a little mvvm theory first.
    http://en.wikipedia.org/wiki/Model_View_ViewModel
    Whatever you do, don't read Josh Smiths explanation.  I used to recommend it but it confuses the heck out newbies. Leave that until later.
    Laurent Bugnion did a great presentation at mix10.  Unfortunately that doesn't seem to be working on the MS site, but I have a copy.  Download and watch:
    http://1drv.ms/1IYxl3z
    I'm writing an article at the moment which is aimed at beginners.
    http://social.technet.microsoft.com/wiki/contents/articles/30564.wpf-uneventful-mvvm.aspx
    The sample is just a collection of techniques really.
    I have a sample which involves no real data but is intended to illustrate some aspects of how viewmodels "do stuff" and how you use datatemplates to generate UI.
    I can't remember if I recommended it previously to you:
    https://gallery.technet.microsoft.com/WPF-Dialler-simulator-d782db17
    And I have working samples which are aimed at illustrating line of business architecture.  This is an incomplete step by step series but I  think more than enough to chew on once you've done the previous stuff.
    http://social.technet.microsoft.com/wiki/contents/articles/28209.wpf-entity-framework-mvvm-walk-through-1.aspx
    The write up for step2 is work in progress.
    https://gallery.technet.microsoft.com/WPF-Entity-Framework-MVVM-78cdc204
    Hope that helps.
    Recent Technet articles: Property List Editing;
    Dynamic XAML

  • "Built In " battery ... what is the best way to deal with it ?

    Hi ... I just bought this laptop envy6-1100se with a built in battery and I actually heard alot of diffrent opinions about the best way to deal with the battery and charging and I don't know what to trust to make my batterylife the longest   so hope u can help me with that .. I want to know also if there is any damage to the battery if I kept it plugged to Ac Power even after it's totally charged ... ??

    You want to minimize the number of charge/discharge cycles so yes it is actually a real good idea to have it plugged in whenever you can. Just to illustrate, Samsung makes several models with integrated batteries and they actually have a setting in the BIOS where you can choose to cut off charging at 80% battery power. If it never goes above 80%, then discharging and charging below the 80% level never registers as a cycle. The battery has a smart chip that counts cycles. After a certain number, say 500, the battery will no longer work. This is to minimize the fire hazard from older Li-ion batteries. In other words, you trade runtime on a "full" charge for longevity of the battery. You might go from 5 hours to 4 on a single charge but the battery will last 4 years instead of two and a half. The battery can actually be replaced but it is a huge pain. The "Samsung" solution is not available on HP's that I have been able to determine.
    So, as I said there is not much you can do except use AC power as much as possible and treat the battery like your life savings; use it sparingly.
    And I recognize that when it comes to batteries on laptops, it is like a discussion of religion. There is more than one respectable opinion but this is mine.

  • A different way to deal with "unknown" user after upgrade from Tiger.

    It's a known issue that doing upgrade and install or archive and install from Tiger to Leopard, produces a lot of folders with "unknown" group in their "get info" panel. This has to do with a different group structure in Tiger and Leopard.
    In Tiger, every user has their own private group with the same name as the username. That group is set to be user's primary group.
    In leopard, every new user with an account is a member of the group staff (gid=20) which is not present in Tiger. Leopard doesn't fully understand Tiger's private group structure, hence the "unknown" group. This causes various problems such as Finder crashes when trying to change the permissions and ownership in the get info window.
    Apple's proposed way of dealing with this is described [here|http://docs.info.apple.com/article.html?artnum=307128].
    However, this method doesn't change the existing group structure and doesn't resolve all the problems.
    I'd like to suggest a different way of dealing with it.
    1. create a new admin user (if you don't have one already), log out of your primary account and log into the new one.
    2. enter the following in terminal:
    *sudo dscl . delete /users/"username"*
    where username is the short name of the user on the main account (not the one you are currently logged into).
    This will delete that user.
    3. Log out/in.
    4. go to system preferences->accounts and create a new user with the name and short name exactly as the one you've deleted in step 2.
    You'll be get a popup saying that a home directory by this name already exists and asking if you want to use it. Say "Yes".
    That's it. Your main user will be recreated using the native group structure of Leopard with gid=20(staff). Permissions on your home directory will be reset with correct group and ownership.
    I tested the process on my powerbook after an upgrade and install from Tiger to leopard and it worked without a hitch.
    I like this method better than Apple's because it completely gets rid of Tiger's group structure which was creating all the confusion. The only downside as far as I can see is that you might have to manually change the group ownership on some files belonging to the main user that sit outside your home directory.
    I would appreciate any comments on this.

    hmm, I confess, I did this before installing 10.5.2 so i can't say for sure. However, I've dealt with a few people (see e.g. this [thread|http://discussions.apple.com/thread.jspa?messageID=7012957]) who are running 10.5.2 and still have this issue. I don't know what if anything 10.5.2 did about this but I'm quite sure that it didn't change the group structure inherited from Tiger.
    Message was edited by: V.K.

  • What is the best way to deal with memory leak issue in sql server 2008 R2

    What is the best way to deal with memory leak issue in sql server 2008 R2.

    What is the best way to deal with memory leak issue in sql server 2008 R2.
    I have heard of memory leak in OS that too because of some external application or rouge drivers SQL server 2008 R2 if patched to latest SP and CU ( may be if required) does not leaks memory.
    Are you in opinion that since SQL is taking lot of memory and then not releasing it is a memory leak.If so this is not a memory leak but default behavior .You need to set proper value for max server memory in sp_configure to limit buffer pool usage.However
    sql can take more memory from outside buffer pool if linked server ,CLR,extended stored procs XML are heavily utilized
    Any specific issue you are facing
    Please mark this reply as the answer or vote as helpful, as appropriate, to make it useful for other readers

  • Best way to deal with hard coded variables in a package

    There is a plsql package that reads a line from a file, parses the data, does a ton of sql operation with it (select update, inserts, calculations) and then writes the output to an output file.
    The file names and the firectories are retieved from a database table.
    Example:
    select location,file_name into loc_in,file_in from temp_tbl;
    p_File_handle := utl_file.fopen (loc_in, file_in, 'W');
    My co worker is suggesting that getting the variable values from the table is not a good practice. He suggests that the values should be hard-coded in the program. Now you might ask what would happen if the file name or directory changes. His suggestion is to have a build file and do a token substitution of those hard coded values in the program and then load in to the DB. In short the process will involve the following steps:
    -Get the package from the repostory.
    -Change the file name and directory in the token file.
    -Run the build process that will replace the values in the package .
    -Load the new file (with the updated values) in to the DB.
    Example:
    This way the program will be initially coded like this:
    p_File_handle := utl_file.fopen ('${loc_in}', '${file_in}', 'W');
    After the build file runs, it will replace the values as
    p_File_handle := utl_file.fopen ('C:/test', 'testfile.dat', 'W');
    Once the file has changed with the new updated values, compile that into the database.
    Ideas/comments?

    Re: Best way to deal with hard coded variables in a package: why have you reposted using a new profile?
    Neither post provides enough clear information on what the actual requirement is. We need more data in order to comment on your idea, your co-worker's, or to suggest alternatives.
    My co worker is suggesting that getting the variable
    values from the table is not a good practice.His reasons for this are...?
    "variable values": Why do they vary? How often do they change?
    The file names and the directories are retrieved from
    a database table.How do the values get into the table? What is the volume of the data?
    Oracle version? Operating system?

  • More efficient way to extract number from string

    Hello guys,
    I am using this Regexp to extract numbers from a string, and I doubt that there is a more efficient way to get this done:
    SELECT  regexp_replace (regexp_replace ( REGEXp_REPLACE ('  !@#$%^&*()_+= '' + 00 SDFKA 324 000 8702 234 |  " ' , '[[:punct:]]',''), '[[:space:]]',''), '[[:alpha:]]','')  FROM dual
    {code}
    Is there a more efficient way to get this done ?
    Regards,
    Fateh                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Or, with less writing, using Perl syntax \D (non-digit):
    SELECT  regexp_replace('  !@#$%^&*()_+= '' + 00 SDFKA 324 000 8702 234 |  " ','\D')
      FROM  dual
    REGEXP_REPLACE(
    003240008702234
    SQL>
    {code}
    SY.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How is the best way to deal with duplicate photos

    I am using a new retina 27" iMac 16gb ram OS X 10.10.1
    Aperture 3.6
    What is the best way to deal with duplicates that get in Aperture Vaults
    I have used Gemini and it finds duplicates, but I have no way of telling if the original are still there.
    I don't want to go through 15000 photos to try to find the duplicate.
    Thanks Charlie

    You mean - one image in a vault, one in a library?  Or duplicates in the same library?
    Photo Sweeper can scan several libraries or folders at the same time and display the duplicates side by side to let you pick which to keep.  You can define rules to mark photos for automatic deletion as well.
    http://overmacs.com/photosweeper.html

  • What's the best way to deal with floating point errors?

    What's the best way to deal with the decimal number errors in Flex?
    Lets say I have:
    var number1:Number = 1.1;
    var number2:Number = 1;
    var result:Number = number1 - number2;
    trace(result);
    I get "0.10000000000000009".
    What's the best way to deal with this so that i get the right result?
    Using the trick: result = Math.round( result * Math.pow(10,13) ) / Math.pow(10,13); is not useful as such when using big numbers.
    For example, If number1 = 100000000001.1, and number2 = 0.2, I get "100000000000.90001" as result. The previous rounding fixes rounding errors after 13th decimal, but here the first rounding errors come after 4 digits.
    The toPrecision method in Number and NumberFormatter dont seem be of use by themselves because of the same reason.
    So I'd have to check how big the number is, and then round the number based on that.
    So far I've constructed a method that does that with logarithms like this:
    public function floatFix(number:Number):Number{
          var precision:int = 14-Math.floor(Math.log(Math.abs(number))*Math.LOG10E);
          var precisionFactor:Number = Math.pow(10, precision);
          return Math.round(Number(number*precisionFactor))/precisionFactor;
    It just seems rather odd that one would have to create and use something like that to just count 1.1-1; There's a lot of calculating in that method, and i'm guessing that having to use that in a loop could slow down a program quite a bit.
    I think there really should be a pre-built method in flex for something like this, but I can't find any.
    Anyone know any better/faster ways?

    Use the application server database pooling services to create a datasource that can be access using JNDI.
    Move the database access code to a Servlet so that a JSP submits a form to the Servlet that does the database access and packages the data into a bean which is passed to another JSP to be displayed.

  • Best way to deal with Mutating table exception with Row Level Triggers

    Hello,
    It seems to be that the best way to deal with Mutating Table exception(s) is to have to put all the trigger code in a package & use it in conjunction with a Statement level trigger .
    This sounds quite cumbersome to me . I wonder is there any alternative to dealing with Mutating table exceptions ?
    With Regards

    AskTom has a good article about this,
    http://asktom.oracle.com/tkyte/Mutate/index.html

  • Best way to deal with multi-track clips?

    Hi,
    I'm editing a documentary using pre edited program masters and have been supplied the audio stems. Can anyone recommend the best way to deal with them so I can access any of the tracks within the main edit.
    I've tried creating a compound clip and adding the stems but I only access to a mono track when using the clip in my main project. I've also tried creating a multicam clip but as my stems need to be split and spaced to line up with the main Pro Res file I don't seem to be able to insert slugs into multicam clip.
    Has anyone found an elegant way to do this?
    Many thanks,
    Leigh

    Hi leiski,
    Happy New Year, and Welcome to the Support Communities!
    Compound clips are still the best way to approach this, because you have access to the stems at any time with a double-click. 
    The following resources may provide additional information:
    Audio editing overview
    http://help.apple.com/finalcutpro/mac/10.1/#verdcd1cc1
    Advanced multichannel audio editing
    Final Cut Pro automatically groups channels into audio components according to how the channels are configured for the clip. You can expand the audio portion of clips to reveal and edit audio components down to the individual channel level. This allows you to apply different effects to different components and streamlines the process for making quick sound cutouts to a single microphone input or other fine adjustments. 
    Important:  Many digital audio file formats, such as AAC and MP3, use interleaved stereo files, which do not contain separate left and right channels. These files appear as a single audio component unless you change the clip’s channel configuration. 
    Keep in mind the following when editing audio components in Final Cut Pro:You view and change the audio channel configuration of your clips in the Audio inspector. You can change audio component names, add or remove audio components, and configure channels in mono, stereo, and surround formats. See Configure audio channels.
    Configure Audio Channels
    http://help.apple.com/finalcutpro/mac/10.1/#verc1fab5f6
    Using Roles to organize clips and export audio files
    http://help.apple.com/finalcutpro/mac/10.1/#verc1faa7ce
    Cheers,
    - Judy

  • Best way to deal with same members having different parents/children

    We have a situation where some nodes need to have different parents for different application but they exist in the main hierarchy. What is the best way to deal with it? The nodes used are pretty much the same.
    Is it best to create a new hierarchy within the same version and let the nodes have different parents in it?
    -- A

    Every node has a parent in the hierarchy. You said that some nodes need different parents for different applications.
    Do these 'different parents' exist further up the tree? If they do then you can create a boolean input property that flags the nodes that exist JUST for the application. Create a new property (call it NewAppParent, let's say) with a formula that recursively climbs up the tree to find its next parent for the application, and export NewAppParent as the parent value.
    If the parent does not exist in the hierarchy then you should create an alternate hierarchy.
    If the parent exists in the hierarchy and is not an ancestor of the node then you're out of luck. Unless you create an alternate hierarchy with unique parent names.
    D

  • What is the proper way to deal with cascading triggers in AcroForms?

    (this has already been posted in the Scripting forum. Due to the lack of response, I am coming here to the Land of C/C++ Developers)
    What is the proper way to deal with cascading triggers in AcroForms?
    My question refers to the forms in which there is a binary question such as:
    "Are you interested in travel?"
    When the user clicks "Yes", there are further questions whose interactive fields are dot.hidden (or "!"), depending on the answer.
    So far, I can handle the 1-level cases fine, but my doubt is how to implement nested dependencies. For the sake of simplicity, I would prefer to define the cause-effect relationship once ("Every time the 'Interested in Travel' box is checked, the field 'International or Domestic' should be visible") and send some sort of message/trigger downstream.
    I would like the right things to happen (cascading triggers included) when the "Clear Form" menu command is selected.
    Are those desirable features available in JavaScript (the particular JS used by the traditional AcroForms)?
    Maybe I should look into C/C++ programming?
    TIA,
    -Ramon

    I guess my problem is that I have some basic college experience in digital circuit design, and would like the forms to be programmed and behave in the same fashion as digital logic.
    The "Clear Form" menu item, of course, would be equivalent to the  reset button.
    Perhaps it is possible to hook my code onto the "Clear Form" menu item?
    -Ramon

Maybe you are looking for