Best way to limit results from a query.

I need to limit the number of results returned from the database to the first x rows. What I need is a database independant way to achieve this - i.e. I can't use LIMIT, TOP, etc. in my query.
My question therefore is does statment.setMaxRows(x) restrict my results at the database level or my application's view to the database? I.e. will the complete SELECT * run within the database but the first x will be returned to the resultset, which could be quite a performance drain at db level. Or will this have the same effect as running a query SELECT TOP X FROM... which will be a much quicker query to run?
Any help greatly appreciated!

The best, and only fool proof way to limit results (rows, columns) from a query, and not waste database resources is to code your query so it only returns the rows and columns that you need. That might mean providing date ranges, sequence number ranges and all other WHERE criteria that can be used to filter the data to exactly what you need.
There are ways to limit what is available to your Java program, but in most cases, the entire SQL must be completed before any results can be returned. The simplest example is; using the SORT command to get the data into the order you require, will first require that all rows be made available to the sort. The fact that you only want the top 5 rows doesn't matter to the DBMS because it cannot give them to you incrementally.
Focus on getting your SQL as efficient as possible. If the SQL runs efficiently, you can use almost any of the JDBC commands to limit, list, cursor forward and backward, etc, without regard to their overhead.

Similar Messages

  • Results from another Query - not available

    HI,
    My environment is Business Objects XI 3.1 SP2 Edge series , i have  below quereis with web Intelligence Reports
    1. not available  the functions/options  Results from another Query(Any) or Results from another Query(ALL) at Query Level.
    2. not getting list of Values for pronpt until i refresh values for prompt?
    Please suggest me is there any fix packs available for the same to availle that functionality.
    Best Regards,
    Reddeppa K

    not getting list of Values for pronpt until i refresh values for prompt?
    There is option called  "Automatic refresh before use"  for the object properties available in the universe designer.
    Please check the box for the object you are using for populating the list of values and export the universe.
    not available the functions/options Results from another Query(Any) or Results from another Query(ALL) at Query Level.
    There is a limitation for the query on query functionality that the both the queries can-not be from the OLAP universe.
    I guess the query which needs to be filtered should be built on universe from the relational data base.
    Regards,
    Rohit

  • Issue with Results from Another Query (Error on Null value)

    Hi All,
    We have a WebI report using "Result from Another Query" option of BO XI R3.1. The report was running fine till recently the dimension object using result from another query had a null value. Report suddenly throwed error as the query filters are invalid.
    Is there a way to make this filter optional if no data/null value is there ? Because we need those null values in report as well.
    Thank you for your time.
    Thanks & Regards
    LN

    Hi Vivek,
    It was not directly solved but I applied alternate logic to over come the issue.
    Here's what I did to overcome:
    I used a sub query in place of the whole result from another query.
    For Ex:
    Dim1 inlist result from another query1
    I made it as
    Dim1 inlist (Dim0)
    where Conditions.
    Here Dim0 is the object which we use for Result from another query and Conditions will be the necessary filter conditions to arrive proper Dim0.  Make sure proper context is formed for the sub query.
    Even though it resolved my problem, It introduces an new issue. It causes increase in query run time when huge set of data is returned from sub query.
    Please let me know if i haven't explained clearly.
    Hi Aris_BO,
    Sorry for not responding earlier.  The logic would probably make more queries null & not null. Thats why I was not advised to use it.
    Thanks
    LN

  • Best way to extract data from archived cube

    Hello Experts,
    Can anyone tell me best way to extract data from archived cube.
    Basically I am trying to pull all the data from archived cube and then load it into another brand new infoprovider which is in different box.
    Also I need to extract all the master data for all infoobjects.
    I have two options in my mind:
    1) Use open hub destination
    or
    2) Infoprovider>display data>select the fields and download the data.
    Is it really possible to extract data using option (2) if records are too high and then load it into another infoprovider in new system.
    Please suggest me the pros and cons for the two options.
    Thanks for your time in advance.

    Hello Reddy,
    Thanks a lot for your quick reply.
    Actually in my case I am trying to extract archived infocube data and then load it into new infoprovider which is in different system. If I have connectivity I can simply export data source from archived infocube and then reload into new infoprovider.
    But there is no connectivity between those two systems (where archived cube is and new infoprovider) and so I am left with the two options I mentioned.
    1) Use Open Hub
    or
    2) Extract data manually from infoprovider into excel.
    Can anyone let me know which of the two options is the best and also I doubt on how to use excel in extracting data as excel have limit of no.of records 65536
    Thanks
    Edited by: saptrain on Mar 12, 2010 6:13 AM

  • How to compare result from sql query with data writen in html input tag?

    how to compare result
    from sql query with data
    writen in html input tag?
    I need to compare
    user and password in html form
    with all user and password in database
    how to do this?
    or put the resulr from sql query
    in array
    please help me?

    Hi dejani
    first get the user name and password enter by the user
    using
    String sUsername=request.getParameter("name of the textfield");
    String sPassword=request.getParameter("name of the textfield");
    after executeQuery() statement
    int exist=0;
    while(rs.next())
    String sUserId= rs.getString("username");
    String sPass_wd= rs.getString("password");
    if(sUserId.equals(sUsername) && sPass_wd.equals(sPassword))
    exist=1;
    if(exist==1)
    out.println("user exist");
    else
    out.println("not exist");

  • How to use Results from Another Query for SAP BW universes

    Hi Everyone,
    I have two SAP BI universes.In my First universe I have Sales Doc no (dimension) and Orderqty (Measure) and in my second universe I have Sales Doc no(Dimension) and BillQty (Measure).
    Here in my first dataprovider I have 1200 rows of data and in second dataprovider I have 75,000 rows. The report should fetch only the BillQty details that matches to corresponding  Sales doc no in first data provider.
    I want to place all these fileds into a single report like as shown.
    (Datarpovider1)                (Datarpovider1)                    (Datarpovider2)
    *Sales Doc No*               Orderqty                           BillQty
    Here I am able to generate single report using merge dimension but it is leading to performance issues. I want to restrict the values at query level by passing the First dataprovider Sales doc no to second Data provider Sales doc number using Results from Anothery Query feature so that It can fetch only the matching records.
    I tried it but it was giving the follwing error:
    A filter contains a wrong value. You cannot run this query. (Error: WIS 00007)
    How Can I get rid of this error. Can we use Results from Anothery Query option for OLAP universe. Are there any limitation on it.
    All this I am doing in Webi Rich Client.
    Appreciate your help
    Thanks &in Advance
    Kiran Saka

    Hi Kiran,
    I think the filter has a wrong operand. For example, a filter with an empty constant, or a filter that deals with numeric values is defined with an alphanumeric value.Check out for this.
    Regards,
    Neeraj

  • How is the best way to remove something from a photo?

    How is the best way to remove something from a photo?

    This is difficult to answer without fully knowing what you are trying to do.
    That said, a few excellent and user friendly retouching tools include:  The Spot Heealing Brush Tool, Healing Brush Tool, Patch Tool, and the Cloning Stamp Tool.

  • How is the best way to read data from an iphone if you lost your itunes data after a crash?

    How is the best way to read data from an iphone if you lost your itunes data after a crash?

    How is the best way to read data from an iphone if you lost your itunes data after a crash?

  • Whats the best way to transfer everything from my old macbook pro to a new mac mini, i have a external hard drive which i backup to regularly via time capsule

    whats the best way to transfer everything from my old macbook pro to a new mac mini, i have a external hard drive which i backup to regularly via time capsule

    Check out > OS X Lion: How to use Migration Assistant to transfer files from another Mac

  • Can we use Result from another query in Webi using Bex uery universe?

    Hi,
    Can we use Result from another query filter option in Webi to create a report using a Bex Query universe?
    I need to create a report using two universes, one is Bex Query Universe and the other is Orcle universe. I have two queries, one is using Oracle universe; the other using Bex Query universe. I need to pass the Oracle data from the Oracle query to the Bex Query query to get the matched data from SAP Bex query.
    I used Result from another query in the query filter panel for the query using Bex query universe. But I got an error saying that 'A filter contains a wrong value. you cannot run this query. (Error: WIS 00007). The data used in the filter on both sides are the same. they are char.
    I have tested by using two queries from the same Bex query universe to see if the Result from another query filter option works. And I got the same error.
    Has anyone run into the same issue and if this is possible and what should be the solution?
    Thanks in advance!
    Edited by: BO_Haiyan on Oct 6, 2010 3:47 PM

    In that situation:
    Create two queries : Oracle and BW query.
    @ Report:
    As you have to see result set from both the Dataproviders, correct? To achieve thise one must have common dimension objects to merge them at report and use Objects those are coming from both queries to use them in single Table/Report.
    Unless you don't use Merge Dimensions, you don't get a chane to use both queries objects in single Table/Report. (It will give tooltip saying: You can't drop here -- Incompatable Objects)
    In case, if you don't have common dimensions, change object definitions to Detail objects, for those required.
    Hope it helps you.
    Thank You!!

  • What could be the best way to Export data from 11.5.8 instance to 12.1.2?

    Hi All
    What could be the best way to Export data from 11.5.8 instance to 12.1.2?
    Release: 11.5.8
    OS: Oracle Solaris on SPARC (32-bit) verison 9
    DB: 9.2.0.1
    Thanks in advance

    What kind of data you are looking to move?
    Database export/import is only supported for full database export/import and the application release should be the same on the source/target nodes.
    You can move the setup using iSetup or FNDLOAD.
    Thanks,
    Hussein

  • What is the best way to import pictures from Lightroom 5 into FCP X

    What is the  best way to transfer pictures from Lightroom 5 into Final Cut Pro X?

    There is no one best way.  If, for instance, you want to be able to zoom into the picture with a Ken Burns effect then you may want to save out a very high res version that will be larger than your video resolution. Just use Lightroom to export a jpg file wherever you want it. You could export it into the Events folder and then choose not to copy it when you import it within FCPx. You could import the picture into iPhoto and then access it directly from within FCPx. Those are two simple, "regular" ways to get it into FCPx but if you are not going to Ken Burns the image by zooming into it and such you will want to crop it in Lightroom to the same size you will be using ie if you are making 720HD video then crop the image to that size and proportion before you export it from Lightroom.

  • What is the best way to import photos from aperture to my new Lightroom

    What is the best way to import photos from aperture to my new Lightroom ?

    See if this helps
    http://lightroomsolutions.com/articles/migrating-from-aperture-to-lightroom-where-do-i-beg in/

  • The best way to import photos from Picasa to iPhoto

    Hi,
    Many of my friends share their pictures online using picasa. Sometimes, I'd like to copy these pictures to keep a backup offline. As a software, I use iPhoto; not picasa. What is the best way to import pictures from picasa to iPhoto?
    I first tried to subscribe to the RSS feed using iPhoto and then copy the pictures from there to my library, but then the dates of the pictures are set wrong: instead of indicating when the picture was shot, it indicates some other date (I guess it indicates the date when the picture was uploaded to picasa).
    Then I decided to install the software picasa.app. From the webalbum of my friends, I could download the pictures directly to picasa.app. Then I exported them to the desktop, and from there imported them to iPhoto. The dates where set correctly, but I lost all the titles and comments of the pictures.
    Do you have any method to download the pictures while keeping both the dates and the titles correctly?
    Thanx!

    There is a direct option in Organizer which lets you import from iPhoto. This is under Import dropdown menu in left panel.
    If you are importing from iPhoto'09, your Tags, Albums Events, captions, star rating would also get imported apart from your media. This works differently for iPhoto'011 where you can get only the media to the Organizer,
    Just a couple of things to know:
    1. If in iPhoto preferences, you have chosen to create copies of your photos in iPhoto library and your library hence refers to the media store inside the library package, then on importing from iPhoto, Organizer would create copies of all those media under your pictures folder. That means, it would not corrupt your iPhoto package or modify it in any way.
    2. However, if in iPhoto, you are organizing by using references to original location on your Hard drive i.e. you are not creating copies of media in iPhoto library then on importing from iPhoto to Organizer, the Organizer would also use the same references and would not create copies of the media.
    Hope that helps!
    ~V

  • Best way to transfer files from old Macbook Pro to new one?

    I just got a new Macbook Pro from Apple...YEEEEAAAHHHH! 
    So....
    What's the best way to transfer files from old Macbook Pro to new one?  I know Migration assistant, but is there a recommended way?  I don't want to put do a system restore or transfer everything from the old laptop, but I do want to move important things like photos, music, documents and such over.  Any suggestions on best way to do this?
    Another question, perhaps subquestion.  If I have, say, an older version of iPhoto but a newer version of one on my new Macbook Pro, will it still transfer photos no problem?
    Just looking for hints from the experts so this puppy is set up in the best way possible.

    Just one comment on this:
    ‘If I have, say, an older version of iPhoto but a newer version of one on my new Macbook Pro, will it still transfer photos no problem?’
    the problems are ALWAYS in the reverse way, when you have the newest (or a newer) version of a given app, and wish to transfer its library to an older version.
    Otherwise, see the link to Pondini.
    I have been using Martin Jahn’s iBackup, with which I have become accustomed and works fine. It also makes daily backups. Its advantage over other apps is that you may add whatever you wish to save, beside its default settings (which you may delete or cancel, of course, even if not recommended); it also has a friendly interface and easily customizable. Of course, this is a personal view, you may try other methods as well, or other backup apps. All are good if you are satisfied and correspond to your needs.

Maybe you are looking for

  • Printout for Delivery Without Picking

    Dear Friends, I have a scenario which says that we have to create a sales order for a scrap sales. This scrap sales have a material which is a non valuated stock and a non inventoried stock. After the sales order is created we need to do a delivery.

  • How do you remove a folder from an itunes library once it's been added?

    How do you remove a folder from an itunes library once it's been added?

  • Contract from srm to SAP R/3

    I made a account assigned pr(with cost centre) in SAP R/3, then i transferred it to SRM, and made a bid in SRM, after all I selected one bid and triggered a contract in SRM so that contract gets made in SAP r/3. Now the contract automatically picks a

  • 5.1 sound in mov

    Earlier I was having problems getting my sound to work. I installed the webdrivers from the site here and I was able to get sound. I wanted to use the software features such as surround mixer so I tried to use the install CD that came with my card. I

  • Customer Balance Report throught Abap

    Hi, I want to develop a report Customer Balance Report in which along with details i have to display the closing and opening balance of it. As per search through SDN i come to know that BSAD,BSID tables to be used so that data can reterived and for c