Any efficient way to select data with limit?

HI
I want to select some rows of my table for showing in a webpage
number of rows is very very much and all of them cannot be showed in one page, so i used paging for my webpage
every page has just 20 rows
problem is here , how to select rows between 400 and 420 ( for example)
i am using this way of query:
select * from
select col1,col2,col3, rownum as r_n
from my table
where ... and .... and ... and ...
order by id desc
where r_n between 400 and 420
this query works, but it is slow. i think database first run inner query and select all rows then select those ones that are in my range
is there any other efficient way to do this?

What is a "realtime response"?
Do they really want the response to be fast on the 200,000th page? Is there actually a use case where a human being looks at 20 rows, hits next, and repeats 200,000 times? Because assuming that the user takes only a second to wait for the page to render, read the results, and hit next, that means that this one user will have spent 3333 minutes/ 55.6 hours/ 2.3 days just looking at results without a break. Are they really going to care at that point if it takes a bit longer to get the next page of results?
Part of being a developer is explaining trade-offs to the customer. If you want the database to page the results by issuing separate queries, the first page of results will be far faster than the 200,000th page. Since users are normally far more concerned about the performance of the first page than the 200,000th, this is generally a reasonable trade-off. There are alternate approaches that will likely improve the performance of fetching the 200,000th page of results. But those will generally require a more complex architecture. For example, you can return a REF CURSOR to the middle tier and let the middle tier fetch a page of results at a time. But then you have to implement the state control logic so that the right end user session sees the right cursor handle and gets the right session back (this problem is much, much easier in a client/server application)
Justin

Similar Messages

  • Select statement with LIMIT

    I m trying to find if LIMIT is a part of the select statement and if works like
    set rowcount 1 in sybase....if anyone can post the generic select statement with LIMIT in it that would be great!
    any help or input will be greatly appreciated
    Thanks!

    Hallo,
    i don't know sybase, but it is probably rownum
    select * from scott.emp
    where rownum < 3
    Regards
    Dmytro

  • Best way to export data with r.t. prompts and have dense dim mbrs on rows?

    Hi All-
    What is the best way to export data with Run time prompts out of Essbase?
    One thought was to use Business Rules with run time variables and DATAEXPORT command, but I came across at least one limitation where I cannot have months (part of dense Time Periods dimension) on rows.
    I have only two dense dimensions: Accounts and Time Periods and I need both of these on rows. This would come handy when user enter Start and End month and year for data to be exported e.g. If start period is Feb 2010 and end is Jan 2011, I get data for all months in 2010 and 2011.
    "CORP1","0173","FY10","Working","Budget","Local","HSP_InputValue","402000",14202.24,14341.62,14560,13557.54,11711.92,10261.58,12540.31,15307.83,16232.88,17054.62,18121.76,18236
    "CORP1","0173","FY10","Working","Budget","Local","HSP_InputValue","403000",19241,21372.84,21008.4,18952.75,23442.13,19938.18,22689.61,23729.29,22807.48,23365,23915.3,24253
    "CORP1","0173","FY11","Working","Budget","Local","HSP_InputValue","404000",21364,22970.37,23186,27302,25144.38,27847.91,27632.11,29007.39,24749.42,27183.39,26599,27112.79
    where ideally I would need to get the following:
    "CORP1","0173","FY10","Working","Budget","Local","HSP_InputValue","402000","Feb",14341.62
    "CORP1","0173","FY10","Working","Budget","Local","HSP_InputValue","402000","Mar",14560
    "CORP1","0173","FY10","Working","Budget","Local","HSP_InputValue","402000","Apr",13557.54
    "CORP1","0173","FY10","Working","Budget","Local","HSP_InputValue","402000","May",11711.92
    "CORP1","0173","FY10","Working","Budget","Local","HSP_InputValue","402000","Jun",10261.58
    "CORP1","0173","FY10","Working","Budget","Local","HSP_InputValue","402000","Jul",12540.31
    "CORP1","0173","FY10","Working","Budget","Local","HSP_InputValue","402000","Aug",15307.83
    "CORP1","0173","FY10","Working","Budget","Local","HSP_InputValue","402000","Sep",16232.88
    "CORP1","0173","FY10","Working","Budget","Local","HSP_InputValue","402000","Oct",17054.62
    "CORP1","0173","FY10","Working","Budget","Local","HSP_InputValue","402000","Nov",18121.76
    "CORP1","0173","FY10","Working","Budget","Local","HSP_InputValue","402000","Dec",18236
    "CORP1","0173","FY10","Working","Budget","Local","HSP_InputValue","403000","Feb",21372.84
    "CORP1","0173","FY10","Working","Budget","Local","HSP_InputValue","403000","Mar",21008.4,
    "CORP1","0173","FY10","Working","Budget","Local","HSP_InputValue","403000","Apr",18952.75
    "CORP1","0173","FY10","Working","Budget","Local","HSP_InputValue","403000","May",23442.13
    "CORP1","0173","FY10","Working","Budget","Local","HSP_InputValue","403000","Jun",19938.18
    "CORP1","0173","FY10","Working","Budget","Local","HSP_InputValue","403000","Jul",22689.61
    "CORP1","0173","FY10","Working","Budget","Local","HSP_InputValue","403000","Aug",23729.29
    "CORP1","0173","FY10","Working","Budget","Local","HSP_InputValue","403000","Sep",22807.48
    "CORP1","0173","FY10","Working","Budget","Local","HSP_InputValue","403000","Oct",23365
    "CORP1","0173","FY10","Working","Budget","Local","HSP_InputValue","403000","Nov",23915.3
    "CORP1","0173","FY10","Working","Budget","Local","HSP_InputValue","403000","Dec",24253
    "CORP1","0173","FY11","Working","Budget","Local","HSP_InputValue","404000","Jan",21364
    Thank you in advance for any tips.

    Have a read of the following post :- export data to sql
    It may give you a further option.
    Cheers
    John
    http://john-goodwin.blogspot.com/

  • Efficient way of updating data to database table

    what is the efficient way of updating data to database table  .
    i have huge amount of data in my internal table  , how to use update statement in this case .
    1. database table having 20 fields  ,
    2. one is key field and suppose 20 th field i want to change  .
    3. I have data for only 2 fields , i.e for ( 1 st and last 20 th field ) .
    i can't use update statement in loop , as it is not good practice(hits database several times ) .
    do it effects all the 20 fields for  particular record .

    Hi,
    Use UPDATE statement , check below description from SAP help.
    UPDATE dbtab FROM TABLE itab. or UPDATE (dbtabname) FROM TABLE itab.
    Effect
    Mass update of several lines in a database table.Here, the primary key for identifying the lines tobe updated and the values to be changed are taken from the lines of theinternal table itab. 
    The system field SY-DBCNT contains the number of updated lines,i.e. the number of lines in the internal table itab which havekey values corresponding to lines in the database table.
    Regards
    L Appana

  • HT1933 Following the instructions above, I'm constantly redirected to this help page rather than receiving any drop down list to select what my problem is. Are there any other ways to report issues with purchases?

    Following the instructions for reporting an issue with a purchase problem, when selecting "report a probelm", I am not provided with a drop down list, I am redirected to the help page instead.
    Is there any other way to report an issue where the app owner has taken the funds twice for the same product at literally the same time?

    To Contact iTunes Customer Service and request assistance
    Use this Link  >  Apple  Support  iTunes Store  Contact

  • Best way to query data with varchar (max) cloumn.

    Hi,
    I have joined  three table and selected 15colmuns over a period of 6months it tooks 10sec .
    I selected two more columns with varchar(max) datatype it took me 60sec.
    whats the best way to select varchar(max) over a period?
    Can anyone please help me on this?
    Thanks,

    I have joined  three table and selected 15colmuns over a period of 6months it tooks 10sec .
    I selected two more columns with varchar(max) datatype it took me 60sec.
    That appears to be normal behavior for any RDBMS.
    You can use the LEFT function to limit transmission volume from server to client:
    SELECT A.Title, A.DocumentSummary INTO tempdb.dbo.DocText
    FROM Production.Document A
    CROSS JOIN Production.Document B CROSS JOIN Production.Document C
    CROSS JOIN Production.Document D CROSS JOIN Production.Document E;
    -- (59049 row(s) affected)
    SET STATISTICS TIME ON
    DBCC DROPCLEANBUFFERS
    SELECT A.Title, A.DocumentSummary FROM tempdb.dbo.DocText A
    DBCC DROPCLEANBUFFERS
    SELECT A.Title, Prefix=LEFT(A.DocumentSummary,10) FROM tempdb.dbo.DocText A
    SET STATISTICS TIME OFF
    SQL Server Execution Times:
    CPU time = 172 ms, elapsed time = 787 ms.
    DBCC execution completed. If DBCC printed error messages, contact your system administrator.
    (59049 row(s) affected)
    SQL Server Execution Times:
    CPU time = 62 ms, elapsed time = 560 ms.s.
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Database Design
    New Book / Kindle: Beginner Database Design & SQL Programming Using Microsoft SQL Server 2014

  • Dynamically select data with 20 input parameters

    Hi Experts,
    Now i have created a subscreen with more than 20 fields on it. these fields are defined by parameters, not select options. user can input any fileds for these input parameters.
    So now i should write codes to select data from database according the user input. Is there any easy way for me to write it? I heard about dynamically SQLs, but i don't know how to use it.
    Thanks a lot!

    you forgot to mention why you needed dynamic SQL : I guess that when user lets a field blank, you must not perform selection on it.
    The easiest is ( FIELD1 = P_FIELD1 OR FIELD1 = space ) AND ( FIELD2 = P_FIELD2 OR FIELD2 = space ) AND etc. Even if it seems repetitive, I advise you to keep the SQL static instead of dynamic, because in this latter case, I think the code will be a little bit less clear.
    Of course, if you argue that there are other requirements, then maybe it's worth re-evaluating the solution.
    If you need more information, just look at ABAP examples in your system (SE38, Environment, Examples, ABAP examples -> ... -> Dynamic conditions)

  • Most efficient way to import data from Excel to InDesign?

    Hi all,
    I'm designing a college prospectus which includes 400+ course listings. At the moment, these listings exist as a vast Excel sheet with fields like course type, course code, description etc.
    I'm familiar with importing Excel data into InDesign and formatting tables/creating table styles and such, but the problem I'm having is that the data is in multiple columns per course in the Excel sheet, but will be arranged in one column per course with multiple rows in the InDesign document. I can't seem to find a way to easily convert these columns into rows.
    Can anyone help me with an efficient way to get the data into the layout without laborious copying and pasting or formatting?
    Many thanks in advance!

    Hi,
    Dans excel coller/ transpose

  • Select data with SDO_RELATE in lat long coordinate system(8307) in 10gR2

    Hi all,
    I have problem with selecting data from table.
    Data are in lat lon coordinate system 8307.
    These requests don't return any data:
    SELECT ISSUE_ID FROM MAP_ISSUES WHERE SDO_FILTER(GEOMETRY, sdo_geometry (2003, 8307, null, sdo_elem_info_array (1,1003,1),sdo_ordinate_array(-180,-90, 180,-90, 180,90, -180,90, -180,-90)) ) = 'TRUE';
    SELECT ISSUE_ID FROM MAP_ISSUES WHERE SDO_RELATE(GEOMETRY, sdo_geometry (2003, 8307, null, sdo_elem_info_array (1,1003,1),sdo_ordinate_array(-180,-90, 180,-90, 180,90, -180,90, -180,-90)), 'MASK=ANYINTERACT' ) = 'TRUE'
    Optimized polygon does return all data correctly:
    SELECT ISSUE_ID FROM MAP_ISSUES WHERE SDO_FILTER(GEOMETRY, sdo_geometry (2003, 8307, null, sdo_elem_info_array (1,1003,3),sdo_ordinate_array (-180,-90,180,90)) ) = 'TRUE'
    Smaller polygon select data correctly too.
    SELECT ISSUE_ID FROM MAP_ISSUES WHERE SDO_FILTER(GEOMETRY, sdo_geometry (2003, 8307, null, sdo_elem_info_array (1,1003,1),sdo_ordinate_array (52,-7, 54,-7 , 54,-5 , 52,-5, 52,-7)) ) = 'TRUE'
    I have tried changed polygon to be clockwise, counter clockwise, make the area a bit smaller( 160 instead of 180, 89 instead of 90) nothing has helped.
    My explanation than was, that Earth is sphere and each defined polygon defines TWO polygons in the sphere and there is convention that the smaller is chosen to select data. It would make sense along the previous results, but than I found one post which says that this is bug http://www.frontoracle.com/oracle-database/703/180703-size-of-are-of-interest-smaller-equals.html
    I have found in other thread that max only 1/2 of Earth could be selected Different results using SDO_RELATE with polygon and rectangle type but it seems not true, because optimized bounding box works fine!
    What is right? Is there anything in official documentation?
    Is it bug.
    Max 1/2 of Earth could be selected in one request.
    Each polygon defines two areas in the Earth and the smaller one is used to do spatial SDO_RELATE operation?
    Thanks!
    Regards,
    Zdenek

    Zdenek,
    A bug, or limititation, whichever you choose. IMHO if you ask for something, and don't get what you expect, it is a bug that could be fixed.
    But for 10g anywho, the following applies, which is why I choose 120 degree breaks for my code as it is less than 180...
    The following size limits apply with geodetic data:
    ■ No polygon element can have an area larger than one-half the surface of the Earth.
    ■ In a line, the distance between two adjacent coordinates cannot be greater than or
    equal to one-half the perimeter (a great circle) of the Earth.
    If you need to work with larger elements, first break these elements into multiple
    smaller elements and work with them. For example, you cannot create a geometry
    representing the entire ocean surface of the Earth; however, you can create multiple
    geometries, each representing part of the overall ocean surface. To work with a line
    string that is greater than or equal to one-half the perimeter of the Earth, you can add
    one or more intermediate points on the line so that all adjacent coordinates are less
    than one-half the perimeter of the Earth.
    Bryan

  • Most efficient way to query dates

    Hi!
    Just wondering if anyone know the quickest or best way to to date comparisons with Oracle. Ie does it take longer for oracle to convert the input date from the inputted date to a date it can use to compare. eg
    iuser.CreateDate <= to_date('07:Dec:2004:11:59:59:PM', 'DD:MON:YYYY:HH:MI:SS:AM')
    OR
    iuser.CreateDate <= to_date('07:12:2004:11:59:59:PM', 'DD:MM:YYYY:HH:MI:SS:AM')

    Hello,
    I have two comments:
    a) what about to use only "<" operator with next day instead of "<="
    iuser.CreateDate <= to_date('07:Dec:2004:11:59:59:PM', 'DD:MON:YYYY:HH:MI:SS:AM')
    iuser.CreateDate < ('08:Dec:2004', 'DD:MON:YYYY')
    b) I think that more faster could be passing the comparision date as date parameter iuser.CreateDate < :inp_test_date.
    sasa

  • Selecting data with cursors on an X-Y Graph

    I would like to make an interactive XY plot with two cursors. These
    cursors will allow the user to select a range of data, and send the
    selected data to an array. Sending the data to an array and referencing
    the positions to the array is no problem, but I cannot get the two
    cursors to work simultaneously.  I am monitoring the positions on
    the front panel, and both indicators display the same data. How do I
    set the property nodes to treat each cursor as separate, and collect
    separate data from each? Thanks.

    Before you can get the cursor index or cursor position, you have to first set the active cursor.
    Message Edited by Dennis Knutson on 03-24-200609:57 AM
    Attachments:
    active cursor.JPG ‏15 KB

  • Most efficiant way of using iPhoto with lightroom

    I am new to mac having moved from pc. I really like the interface and publish features of iphoto. I'm quite a serious photography so I want to use lightroom for the more professional features but continue with iPhoto for the family to browse my personal and better work through the simpler iphoto interface.
    2 questions really. I want lightroom to access all my photos so will I be importing photos to folders in pictures like I used to do with pc rather than importing them through iPhoto because of the package file.
    And what is the best way of putting better work into iPhoto without duplicating a lot of files.
    Hope you can help

    This post by Terence Devlin will give you some info:
    http://discussions.apple.com/message.jspa?messageID=7764845#7764845
    TIP: For insurance against the iPhoto database corruption that many users have experienced I recommend making a backup copy of the Library6.iPhoto (iPhoto.Library for iPhoto 5 and earlier) database file and keep it current. If problems crop up where iPhoto suddenly can't see any photos or thinks there are no photos in the library, replacing the working Library6.iPhoto file with the backup will often get the library back. By keeping it current I mean backup after each import and/or any serious editing or work on books, slideshows, calendars, cards, etc. That insures that if a problem pops up and you do need to replace the database file, you'll retain all those efforts. It doesn't take long to make the backup and it's good insurance.
    I've created an Automator workflow application (requires Tiger or later), iPhoto dB File Backup, that will copy the selected Library6.iPhoto file from your iPhoto Library folder to the Pictures folder, replacing any previous version of it. It's compatible with iPhoto 6 and 7 libraries and Tiger and Leopard. Just put the application in the Dock and click on it whenever you want to backup the dB file. iPhoto does not have to be closed to run the application, just idle. You can download it at Toad's Cellar. Be sure to read the Read Me pdf file.
    Note: There's now an Automator backup application for iPhoto 5 that will work with Tiger or Leopard.

  • Designing View to select Date with Time

    Hi,
    How can we design the view to select the date along with time?
    We know that we can provide drop downs for hours, minutes and seconds.
    Is there any alternative to display UI element to select the date and time. I am in 7.0 SP17
    Thanks

    Hi Tatayya Marni,
    For selecting the Date and Time u can try a workaround. First create a simple type of type date and bind it to an Input Field so that the date can be captured and for the for the time u can use the System Date and using the same SystemDate u can get the Time in Hours, Minutes and Seconds.
    Eg  :- store the SystemDate in a Date variable and to get the hour u can use Date.getHours(), getMinutes
        Date dt = new Date(System.currentTimeMillis());
        dt.getHours(),dt.getMinutes(),dt.getSeconds());
    Hope this works dor u.
    Regards,
    Poojith M V

  • Any sample program to fetch data with JSP from MySQL

    Hi,
    Anybody can you ple give me a sample code to fetch data from MySQL and show it.
    Database server : localhost
    Databasename : test
    Database User : root
    Database Password : (database have no password)
    Table Name : category
    Table column name : catName
    I am trying the following code, but it gives error:
    exception
    org.apache.jasper.JasperException: javax.servlet.ServletException: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
         org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:522)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:398)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    <%@ page import="java.sql.*" %>
    <%
    String connectionURL = "jdbc:mysql://localhost:3306/test";
    Connection connection = null;
    Statement statement = null;
    ResultSet rs = null;
    %>
    <html><body>
    <%
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    connection = DriverManager.getConnection(connectionURL, "root", "");
    statement = connection.createStatement();
    rs = statement.executeQuery("SELECT * FROM category");
    while (rs.next()) {
    out.println(rs.getString("catName")+"<br>");
    rs.close();
    %>
    </body></html>
    any help is appreciated.
    ---Sujoy

    Just replace the following code. I think it will work for u.
    <%@ page import="java.sql.*" %>
    <%
    try{
    String connectionURL = "jdbc:mysql://localhost:3306/test";
    Connection connection = null;
    Statement statement = null;
    ResultSet rs = null;
    Class.forName("com.mysql.jdbc.Driver");
    connection = DriverManager.getConnection(connectionURL, "root", "");
    statement = connection.createStatement();
    rs = statement.executeQuery("SELECT * FROM category");
    %>
    <html><body>
    <table>
    <%
    while(rs.next())
    %>
    <tr><td><%=rs.getString("catName")%></td></tr>
    <%
    %>
    </table>
    </body>
    </html>
    <%
    rs.close();
    statement.close();
    connection.close();
    catch(Exception e)
           e.printStackTrace();
    finally()
      try{
       rs.close();
       statement.close();
       connection.close();
      catch(Exception e)
            e.printStackTrace();
    %>

  • How to select data with multiple child nodes

    We have the following data:
    me table ei table
    m1 e1
    m1 e2
    m1 e3
    m1 e4
    m2 e5
    m2 e6
    m3 e7
    m3 e8
    I would like to display them as:
    m1 e1
    e2
    e3
    e4
    m2 e5
    e6
    m3 e7
    e8
    How to best do this with sql?
    I would like to produce this list with sql and then transform it to xml.
    Thanks.

    Since you did not use tags it is not clear what results should be:
    SQL> WITH TBL AS (
      2  SELECT 'm1' me, 'e1' ei FROM DUAL UNION ALL
      3  SELECT 'm1' me, 'e2' ei FROM DUAL UNION ALL
      4  SELECT 'm1' me, 'e3' ei FROM DUAL UNION ALL
      5  SELECT 'm1' me, 'e4' ei FROM DUAL UNION ALL
      6  SELECT 'm2' me, 'e5' ei FROM DUAL UNION ALL
      7  SELECT 'm2' me, 'e6' ei FROM DUAL UNION ALL
      8  SELECT 'm3' me, 'e7' ei FROM DUAL UNION ALL
      9  SELECT 'm3' me, 'e8' ei FROM DUAL
    10  )
    11  SELECT  CASE ROW_NUMBER() OVER(PARTITION BY ME ORDER BY EI) WHEN 1 THEN ME ELSE NULL END ME,
    12          EI
    13    FROM  TBL
    14    ORDER BY TBL.ME,
    15             TBL.EI
    16  /
    ME EI
    m1 e1
       e2
       e3
       e4
    m2 e5
       e6
    m3 e7
       e8
    8 rows selected.or
    SQL> WITH TBL AS (
    2 SELECT 'm1' me, 'e1' ei FROM DUAL UNION ALL
    3 SELECT 'm1' me, 'e2' ei FROM DUAL UNION ALL
    4 SELECT 'm1' me, 'e3' ei FROM DUAL UNION ALL
    5 SELECT 'm1' me, 'e4' ei FROM DUAL UNION ALL
    6 SELECT 'm2' me, 'e5' ei FROM DUAL UNION ALL
    7 SELECT 'm2' me, 'e6' ei FROM DUAL UNION ALL
    8 SELECT 'm3' me, 'e7' ei FROM DUAL UNION ALL
    9 SELECT 'm3' me, 'e8' ei FROM DUAL
    10 )
    11 SELECT CASE ROW_NUMBER() OVER(PARTITION BY ME ORDER BY EI) WHEN 1 THEN ME ELSE EI END ME,
    12 CASE ROW_NUMBER() OVER(PARTITION BY ME ORDER BY EI) WHEN 1 THEN EI ELSE NULL END EI
    13 FROM TBL
    14 ORDER BY TBL.ME,
    15 TBL.EI
    16 /
    ME EI
    m1 e1
    e2
    e3
    e4
    m2 e5
    e6
    m3 e7
    e8
    8 rows selected.
    SQL>
    SY.

Maybe you are looking for