Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8373203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:37:13+00:00 2026-06-09T14:37:13+00:00

I have two applications : the first one inserts data in the table MyTable

  • 0

I have two applications : the first one inserts data in the table MyTable. The second one reads the rows of the table MyTable in chunks : let’s say 1000 rows per read. This second app must read the data in chronological order, and use a query similar to :

SELECT
    C1,
    C2
FROM
(
    SELECT
        rownum AS RowNumber, 
        C1, 
        C2
    FROM
        MyTable
    WHERE
        C3 = :C3
        AND IsProcessed = 0
    ORDER BY
        Timestamp
) temp 
WHERE 
    temp.RowNumber <= 1000

The query works, but it is slow (more than one minute, usually it takes only a few seconds to execute) when a lot of not processed rows (for example 10 millions) are waiting in the table MyTable. I suppose this is normal, because Oracle must first sort all the concerned rows in the chronological order…
So my question is : is there a better way to write this query ?

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T14:37:15+00:00Added an answer on June 9, 2026 at 2:37 pm

    From your execution plan, I’m guessing that your predicate C3 = :C3 is quite costly. You should try to optimise that by avoiding RAW types. There are several options:

    • Ensure you have an index on SUBCONTRACTID
    • Try adding a function-based index on NVL(BUSINESSTRANSACTIONID, HEXTORAW('00'))
    • Ensure you have an index on BUSINESSTRANSACTIONID and query that using IS NULL, rather than NVL(...)
    • If you can relax the underlying business requirement, it would of course help to remove the ORDER BY timestamp clause and process records in arbitrary order.

    Apart from that, your query seems fine.

    Also, try applying a /*+FIRST_ROWS(1000)*/ hint, as it seems that this isn’t done automatically for some reason in your query, even with ROWNUM filtering

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two applications first one is application1 and second application1+ and how to
I have two silverlight applications. I want to reference the first one from the
I have an application that has two threads. The first one (the main thread)
I have two desktop applications. After closing the first application, the first application will
I have a database that is accessed by two applications. The first is an
I have application where i have two view controllers my first view and second
In my application i have two drop down boxes first box had origin second
I have two applications in my project 'test' the applications are one.mxml and two.mxml
I have here two applications in two different projects in eclipse. One application (A)
Hi everyone let me explain this issue: Background: I have two web applications The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.